I have the following:
<input name="Check100" type="checkbox">
<tr>
<td><input name="ClassIDs" type="checkbox" value="3132">
<td>50</td>
</tr>
<tr>
<td><input name="ClassIDs" type="checkbox" value="3133">
<td>100</td>
</tr>
<script>
$('input[name=Check100]').change(function() {
var myChecked = $(this).attr('checked');
$('input:checkbox').attr('checked',myChecked);
});
</script>
But what I need to do is toggle all the inputs that have a 100 in column 2.
I first thought of using :contains() but when I read the documenation i realized that it checks for exactly what it says, if it contains something, not the exact match. I didn’t find any shorthand function for this, but you can use filter().
For example, :contains(‘100’) will also match 1000.
Code:
Example: http://jsfiddle.net/FEP5u/
Update:
Enhanced version: http://jsfiddle.net/FEP5u/2/
Using IDs at your elements and as your selectors improves the speed.
And the HTML spec says (I think) that attributes like checked should be removed instead of being set to false.
HTML:
Javascript: