I have the following code:
<input type="checkbox" name="module" value="module1" />
<input type="checkbox" name="module" value="module2" />
<input type="checkbox" name="module" value="module3" />
<div id="result"></div>
And the Javascript:
$('input[name="module"]').click(function(){
if (this.checked) {
var span = "<span id='" + this.value + "'>" + this.value + "<br /></span>";
$("#result").append(span);
}else{
$("#" + this.value).remove();
}
});
All this works well. However, when I introduce a value for the checkbox with a space in it stops removing the item from the list.
http://jsfiddle.net/n1cubk0e/5/
You can see from the above what happens when a space is introduced. How to I get it to work with the space in the checkbox value?
Thanks in advance