Hello I am making a script to check all slave checkboxes related to master checkbox. This will be done using classes. So master checkboxes will have classes like “master1”, “master2” etc.. The related slave checkboxes gonna have “slave1” class (related to master1), “slave2” (related to master2) etc..
so I’ll begin with:
jQuery('.checks_div input[type="checkbox"].^="master"').click(function(){
So when the master was clicked I want to choose all related slave and check them. But how?
Thanks
but delegating is better
then inside the click function & if you have your slaves in an adjacent div to the master checkbox
if html is different well come out with a way to select those slaves from this $(this) that is the box just checked
once your slaves are in a jquery object, to check them :
see Setting "checked" for a checkbox with jQuery?
if you do nothing else than check them you don’t even need to cache your slaves in a jquery object