Possible Duplicate:
jQuery value selector
I have this as html:
<div style="" id="results">
<label class="wList"><input checked="checked" class="wList-chk" name="wList[]" value="6" type="checkbox">Running</label>
<label class="wList"><input checked="checked" class="wList-chk" name="wList[]" value="1" type="checkbox">Baseball</label>
<label class="wList"><input checked="checked" class="wList-chk" name="wList[]" value="3" type="checkbox">Basketball</label>
</div>
I want to access a checkbox by value and was wondering how this is done. I have tried:
$("#results .wList .wList-chk input:checkbox").attr('value').effect('highlight',{},1500);
What am I doing wrong?
There are lots of ways, one of which is:
However this will only select the checkbox and not the text around it. What you probably want it:
jsFiddle example
This will select the label and the text within it.