jquery simple implementation of all-select and inverse selection

Source: Internet
Author: User

Full selection and anti-election believe in the actual development often used, the following demo a piece of code;

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>JQ simple implementation of full selection and inverse selection</title>    <Scriptsrc= "Jquery-3.1.0.js"></Script></Head><Body><DivID= "DV">    <inputtype= "checkbox"/><BR/>    <inputtype= "checkbox"/><BR/>    <inputtype= "checkbox"/><BR/>    <inputtype= "checkbox"/><BR/>    <inputtype= "checkbox"/><BR/></Div><HR/><inputtype= "button"ID= "SelectAll"value= "Select All"/><inputtype= "button"ID= "Noselect"value= "All is not selected"/><inputtype= "button"ID= "Select"value= "Reverse Selection"/><Script>    //Select All    $ ( '#selectAll'). Click (function () {        $ ( '#dv >input'). each (function(i, v) {//the parameters of the function can not be passed             This. Checked= true;//return false; return false to jump out of the current loop, when the function executes only once        } )    } )    //all do not choose    $ ( '#noSelect'). Click (function () {        $ ( '#dv >input'). each (function(i, v) { This. Checked= false; } )    } )    //Inverse Selection    $ ( '#select'). Click (function () {        $ ( '#dv >input'). each (function(i, v) { This. Checked= !  This. Checked; //the selected state is now the opposite of the current        } )    } )</Script></Body></HTML>

jquery simple implementation of all-select and inverse selection

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.