Goods: The Click event of the Select button of the shopping cart module and the item's check button

Source: Internet
Author: User

1<script type= "Text/javascript" >2     /*3 Calculate Total Method4      */5$(function() {6 7Showtotal ();//calculate totals when the document is loaded8 9         //Add Click event to select AllTen$ ("#selectAll"). Click (function() { One             //Get the status of select all A             varBOOL = $ ("#selectAll"). attr ("checked")); -             //Synchronize all of the entry's check boxes with the Select All button state - Setitemcheckbox (bool); the             //Synchronize the Settle button with the state of select all - Setjiesuan (bool); -  -             //Recalculate Totals + showtotal (); -  +         }); A  at         //Add the Click event to the check box for all entries -$ (": CheckBox (NAME=CHECKBOXBTN)"). Click (function() { -  -             //take out the number of all items -             varAll = $ (": checkbox[name=checkboxbtn]"). length; -             //take out the selected number in             varselect = $ (": Checkbox[name=checkboxbtn][checked=true]"). Length -  to             if(All = =Select) { +                 //tick the Select All button -$ ("#selectAll"). attr ("Checked",true); theSetjiesuan (true); *}Else if(select = = 0) { $$ ("#selectAll"). attr ("Checked",false);Panax NotoginsengSetjiesuan (false); -  the}Else { +$ ("#selectAll"). attr ("Checked",false); ASetjiesuan (true); the             } + showtotal (); -  $         }); $  -     }); -  the     functionshowtotal () { -         varTotal = 0;Wuyi         //1 Get all the checked check blocks the$ (": Checkbox[name=checkboxbtn][checked=true]"). each (function() { -             //2 Gets the value of the check block, which is Cartitemid Wu             varID = $ ( This). Val (); -             //3 and then find the subtotal by Cartitemid to get the content About             varText = $ ("#" + ID + "Subtotal"). text (); $             //4 Cumulative operation string accumulation will grow longer -Total + =Number (text); -  -         }); A         //5 totals displayed in total element +$ ("#total"). Text (total); the  -     } $  the     //Set the check button for all entries uniformly the     functionSetitemcheckbox (bool) { the$ (": checkbox[name=checkboxbtn]"). attr ("Checked", BOOL); the  -     } in  the     //Set the settlement button style the     functionSetjiesuan (bool) { About         if(bool) { the$ ("#jiesuan"). Removeclass ("Kill"). AddClass ("Jiesuan"); the             //write off the previous event the$ ("#jiesuan"). Unbind ("click");//undo All Click events for the current element +}Else { -             //Styling styles in CSS the$ ("#jiesuan"). Removeclass ("Jiesuan"). AddClass ("Kill").);Bayi             //Set hyperlink Unavailable click returns False the$ ("#jiesuan"). Click (function() { the                 return false; -             }); -         } the  the     } the</script>

Goods: The Click event of the Select button of the shopping cart module and the item's check button

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.