Jquery checkbox full selection method code attachment JS checkbox full selection inverse selection code

Source: Internet
Author: User

The jquery method is as follows: CopyCode The Code is as follows: function checkall (VAL ){
$ ("Input [name = 'chkjob']"). Each (function (){
This. Checked = val;
});
$ ("# Chkall"). ATTR ("checked", Val); // you can specify the status of the Select All button.
}

Val this parameter specifies the selection status of the Select All button.
name = 'chkjob' indicates the checkbox name in the list.
chkall indicates the name of the Select All button.
I like jquery's simplicity and clarity...
it's really a little different from what I wrote with JavaScript!
eg:
select all JavaScript code copy Code the code is as follows: // select all
function checkall () {
var all = document. getelementsbytagname ("input");
for (VAR I = 0; I If (ALL [I]. type = "checkbox") {
All [I]. checked = true;
}< BR >}< br> // reselect
function checknull () {
var all = document. getelementsbytagname ("input");
for (VAR I = 0; I If (ALL [I]. type = "checkbox") {
All [I]. checked = false;
}< BR >}

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.