Implementation Code of jquery all-selected, all-unselected, and invert-selected results [recommended], jquery all-selected

Source: Internet
Author: User

Implementation Code of jquery all-selected, all-unselected, and invert-selected results [recommended], jquery all-selected

Implementation Code of jquery all-selected, all-unselected, and invert selection results [recommended]

First, introduce jquery

<Title> haran.info _ jquery instance _ select all do not select inverse _ select-all_unselect-all_reverse </title> <meta http-equiv = "content-type" content = "text/html; charset = UTF-8 "/> <script src ="/js/jquery-1.8.3.min.js "type =" text/javascript "> </script> <! -- Introduce Jquery -->

Style:

<styletype="text/css"><!--#div1{  width:980px;  margin:0 auto;  position:relative;  text-align:left;  padding-left:400px;  line-height:30px;  border:1px dotted #0075c5;}li{  display:block;  list-style:none;  float:left;  position:relative;  padding-left:20px;}.clr{  height:20px;}--></style> 

Body layout:

<Divid = "div1"> <divclass = "clr"> </div> <! -- Option start --> <inputtype = "checkbox"/> <ahref = "haran.info"> haran.info _ Script Programming </a> <br/> <inputtype = "checkbox"/> <ahref = "haran.info"> haran.info _ website programming </a> <br/> <inputtype = "checkbox"/> <ahref = "haran.info"> haran.info _ system management </ a> <br/> <inputtype = "checkbox"/> <ahref = "haran.info"> haran.info _ server configuration </a> <br/> <inputtype = "checkbox "/> <ahref = "haran.info"> haran.info _ system O & M </a> <br/> <inputtype = "checkbox"/> <ahref = "haran.info"> haran. I Nfo _ blog </a> <br/> <inputtype = "checkbox"/> <ahref = "haran.info"> haran.info _ homepage </a> <br/> <! -- Option END --> <! -- Function button start --> <inputtype = "button" id = "selAll" value = "select all"/> <inputtype = "button" id = "unselAll" value = "None "/> <inputtype =" button "id =" reverse "value =" invert "/> <! -- Function button ends --> <divclass = "clr"> </div> <! -- Disable div1 -->

Functions:

<Scripttype = "text/javascript"> $ (document ). ready (function () {$ ("# selAll "). click (function () {// ": checked" matches all the check boxes $ ("# div1: checkbox "). attr ("checked", true); // "# div1: checked" must be separated by spaces. checked indicates the selected status. If it is true, select fo; otherwise, false is not selected.}); $ ("# unselAll "). click (function () {$ ("# div1: checkbox "). attr ("checked", false) ;}); // use the iteration principle each (function () {}) $ ("# reverse "). click (function () {$ ("# div1: checkbox "). each (function () {$ (this ). attr ("checked ",! $ (This). attr ("checked "));//! $ (This). attr ("checked") determines the status of the check box: if selected, the status is reversed.}) ;}); </script>

The implementation code [recommended] of jquery's all-selected, all-unselected, and invert selection results is all the content shared by Alibaba Cloud. I hope you can provide a reference and support for the customer's house.

Related Article

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.