I have successfully generated dynamic checkboxes, I am trying to make a select all function to select some specific checkboxes. all the check boxes has a dynamic class name as follow
** HTML **
<input type="checkbox" value="None" id="itemselect" class="NP<seperator><?php echo $productId; ?>" name="itemselect" />
and some other check boxes are generated as:
<input type="checkbox" value="None" id="itemselect" class="OS<seperator><?php echo $productId; ?>" name="itemselect" />
What I have to do is to select class="NP........" on select all checkbox checked.
I have checked stack overflow and I found the bellow suggestion that, kind of answering my issue but in the alert I get object object while I supposed to get NP separator and the productId.
Please help me to find out what is wrong with my code.
$(document).ready(function() {
$("#itemselectall").on("click", function() {
var all = $(this);
$('input:checkbox').each(function() {
var classchkd = $(this).attr('class', all.attr('class'));
alert (classchkd);
});
});
});
id="itemselect"should only occur once.