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