I have this code:
if $('#myDiv').find('input[type=checkbox]:checked').removeAttr('checked');
Unchecks all checkboxes is there a line of code that will add the check to all of the checkboxes without looping each checkbox?
I've tried:
$('#myDiv' input[type="checkbox"]').prop('checked', $(this).prop('checked'))
;
But that did not work. Can someone help me?
Try
$('#myDiv input:checkbox').prop('checked', true);
$('#myDiv input:checkbox').attr('checked', true);
Note: $( ":checkbox" )
is equivalent to $( "[type=checkbox]" )
Try this:
$('#myDiv input:checkbox').attr('checked',true);
As per the accepted answer this only works for jquery 1.5.x and below.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.