Select All zepto buttons and change the status based on whether all the buttons are selected. Select All zepto buttons.

Source: Internet
Author: User

Select All zepto buttons and change the status based on whether all the buttons are selected. Select All zepto buttons.

During secondary development shopping cart on the mobile phone end, I found that zepto was all selected, not found, or the function was not what I wanted.

Later, I made a good job and shared it with the people who needed it.

 

// Select all or multiple processes
Var CheckAll = $ ('# items_check_all ');
Var checkbox = $ ('input [name ^ = "check"] ');
Var removeUrl = '<{link app = B2C ctl = wap_cart act = remove}> ';

// Initialize and add all selected States
If (CheckAll & checkbox ){
('.Pt-h-item'hangzhou.addclass('active'hangzhou.css ('background ',' # efefef ');
}

// Select all or none
CheckAll. on ("click", function (){
If (this. checked ){
Checkbox. prop ('checked', true );
// Configure ('.pt-h-item'hangzhou.addclass('active'hangzhou.css ('background ',' # efefef ');
} Else {
Checkbox. prop ('checked', false );
// Configure ('.pt-h-item'mirror.removeclass('active'mirror.css ('background ',' # fff ');
}
});

// Select all button for reverse association after single choice
Checkbox. on ("click", function (){
Var flag = true;
Checkbox. each (function (item ){
Var parent = $ (this). parents ('. pt-h-item ');
If (! This. checked ){
Flag = false;
Parent.removeclass('active'background .css ('background', '# fff ');
} Else {
Parent.addclass('active'hangzhou.css ('background', '# efefef ');
}
})
If (flag ){
CheckAll. prop ('checked', true );
} Else {
CheckAll. prop ('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.