Select and deselect all checkbox using jQuery

Опубликовано: 16 Октябрь 2024
на канале: Jiansen Lu
3,136
9

I found some codes only work for the first and second click, failed for third click after.
This code works for no matter how many times to check in select all check box.
JavaScript function selectAll is used
function selectAll(status) {
$('input[name=selectedId]').each(function(){
$(this).prop('checked', status);
});
}
called by selected input box:
input type="checkbox" id="selectall" onclick='selectAll(this.checked)'
More about this video and code:
http://jiansenlu.blogspot.ca/2013/09/...