The jquery method is as follows:
function CheckAll (val) {
$("input[name='chkJob']").each(function() {
this.checked = val;
});
$("#chkAll ").attr("checked", val);//Set the select-all button state
}
val This parameter passes the selection state of the select-all button
name= 'chkJob' is the name of the checkbox in the list
chkAll is the name of the select all button
I like the simplicity and clarity of Jquery...
There is really a gap compared to writing in JavaScript!
eg:
javascript select all and inverse select code
//Select all
function checkall() {
var all = document.getElementsByTagName("input");
for (var i = 0; i < all.length ; i ) {
if (all[i].type == "checkbox") {
all[i].checked = true;
}
}
}
/ /Inverse selection
function checknull() {
var all = document.getElementsByTagName("input");
for (var i = 0; i < all.length; i ) {
if ( all[i].type == "checkbox") {
all[i].checked = false;
}
}
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn