Jquery checkbox Full Selection method code with JS checkbox full selection of the reverse code _jquery

Source: Internet
Author: User
The jquery method is as follows:
Copy Code code as follows:

Function Checkall (val) {
$ ("Input[name= ' Chkjob ']"). each (function () {
this.checked = val;
});
$ ("#chkAll"). attr ("Checked", Val);//Set all Select button Status
}

Val, this parameter passes the selection state of the full selection button.
Name= ' Chkjob ' This is the name of the checkbox in the list
Chkall is the full Select button name
Love the simplicity and clarity of jquery ...
It's a little bit different from what you write with JavaScript!
eg
JavaScript Select All-in-selection code
Copy Code code as follows:

//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;
}
}
}
//Checknull
Function-() {
var all = document.getElementsByTagName ("input");
for (var i = 0; i < all.length i++) {
if (All[i].type = = "checkbox") {
all[i].checked = false;
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.