Jquery get class name by partial name
jquery
Solution
$('input[type="checkbox"][class^="master"]').on("click",function(){})
but delegating is better
$(document.body).on('click','input[type="checkbox"][class^="master"]',function(){})
then inside the click function & if you have your slaves in an adjacent div to the master checkbox
var $slaves=$(this).next().find('input[type="checkbox"][class*="slave"]')
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 :
$slaves.prop('checked', true);
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
$(this).//chain to select slaves
.prop('checked', true)
Problem
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