My problem is that when the checkbox below is clicked – the check function is called to check/uncheck all the checkboxes. But they have to change relatively to the invoking checkbox (the one with the “onchange” event).
The checkbox HTML declaration:
<input type="checkbox" onchange="$('input[type=checkbox][rel=users]').check();">
Sample JavaScript Code:
$.fn.check = function() {
$(this).each(function(){
$(this).attr('checked', checked);
});
}
And my question is: How can I get the DOM object corresponding to the “check all” checkbox?
Edit: Pass the
thisobject of the checkAll to the function.DEMO
Note the
thisis passed as.check(this)And in the JS:
Old Post –
Bind the checkAll checkbox to an handler and call the fxn from inside.. See below,
HTML
JS