Jquery Implement intelligent All-select Plug-ins

Source: Internet
Author: User
Tags implement

According to everyone's opinions on the procedures in some of the bad writing, but also the level of my limited, there are a variety of places to consider.

At the end of the article I raised a question, to write a general method to call, so I have the present article, the evening home, I wrote the effect

The following examples can be used to discuss learning, if you feel good can also be applied directly to the project.

Development process: To achieve universal will solve 2 problems, how to group, how to determine which checkbox in the group for all election, I think, think by name Group can,

Use class to determine whether a checkbox group that requires a full selection. Find all classes First and then find the Name property, and you can find the other child checkbox based on the Name property, as long as you find the element, you can do it.

Here is my implementation of JS, save for Xs_checkbox_all.js

Author: frivolous scholar//Blog address: http ://www.cnblogs.com/xiaoshuai1992//CREATE:2014/1/15//function: To implement the smart selection//Usage of a checkbox: Refer to jquery, set the name of the checkbox group to select All, All selected checkbox set class to the following variable Xschk//*********************************************************************************  $ (document). Ready (function () {    var xschk = "Xschk";//Defined style     var xschkall = "Input[type= ' checkbox '][class= '" + xschk + "'][name]";//All checkbox     $ (xschkall) that define this style. each ( function () {        var name = $ (this). attr ("name");          name = "input[type= ' checkbox '][class!= '" + xschk + "'][name= '" + name + "']";//the Child checkbox under this Full selection box  & nbsp;      $ (this). Click (function () {        
    $ (name). attr ("Checked", $ (this) [0].checked);        })         var xschk = $ (this);         $ (name). Click (function () {             var iall = $ (name). length; The number of all the checkbox under this subproject             var ichk = $ (name + ": Checked "). Length; The number of all checkboxes under this subproject             var isallchecked = true; Whether it is a full selection             if (Iall!= ichk) {   
             isallchecked = false;            }        
     $ (XSCHK). attr ("Checked", isallchecked);

       });
   }); });

Page Use

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
">  


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.