$(function(){ //全选改变事件 $(".checkAll").change(function(){ // alert($(this).prop("checked")); $(".checkAll,.check").prop("checked",$(this).prop("checked")); }); //子勾选框的点击事件 $(".check").click(function(){ // alert($(".check:checked").length); if($(".check:checked").length==3){ $(".checkAll").prop("checked",true); }else{ $(".checkAll").prop("checked",false); // Get the number of values $ (. "The Add"). The Click (function () { }) } // number of clicks increase, and change the total amount of the price n-$ = var (the this) .siblings (. "NUM") Val ();. n-++; $ (the this) .siblings ( "NUM.") Val (n-);. The number of each of +1 // Assignment the input value to // get the current unit price of commodities, and the ¥ removed var. price = $ (the this) .parent () SIBLINGS text () substr (. 1). ( ". price.");.. @ calculated current product the total amount assigned to a total of one and two decimals $ (the this) .parent () SIBLINGS ( "COUNT.") text ( "¥" + (the n-*. price) .toFixed (2));.. GetSum (); }) // decrease the number of clicks, and change the total price amount $ (.. "the reduce") the click (function () { var = n-$ (the this) .siblings (. "NUM") Val (). ; if(n==1){ return false; }else{ n--; } $ (The this) .siblings ( "NUM.") Val (n-);. . Var. Price = $ (the this) .parent () SIBLINGS ( ". Price.") Text () substr (. 1);.. $ ( the this) .parent (.) SIBLINGS ( "COUNT.") text ( "¥" + (n-*. price.) .toFixed (2)); GetSum (); }) // changed according to the number of input total amount of $ ( ".num") Change (function () {. var = n-$ (the this) .val (); // get the number of values // Get current product monovalent var price = $ (this) .parent () siblings (. ".price") text () substr (1);.. // calculate the current total amount of goods, assigned to count, and two decimal places }); // total and total,The number of addition and subtraction, manually adjust the quantity used at all, so you can use functions to facilitate multiple call .. $ (this) .parent ( ) siblings ( "count ") .text (" ¥ "+(price*n).toFixed(2)); GetSum (); $ (. "del").click(function(){ GetSum (); function GetSum () { var Counts = 0; var Prices = 0; // calculate totals . $ (. "NUM") each (function (I, ELE) { Counts + = the parseInt ($ (ELE) .val ()); }) . $ (. "the nums") text (Counts); // calculate the total amount . $ (. "COUNT") each (function (I, ELE) { Prices + = parseFloat (($ (ELE) . .text ()) substr (1)); }) $ (. "Prices") text ( "¥" + prices.toFixed (2));. } // click the delete button to delete the current product $ (this) .parents ( "tr") remove ( ).; }); // delete all items $ ( "Removes.") The Click (function () {. $ ( "The Check.") Parents ( "trs.") The Remove ();.. }) // click Delete checked merchandise $ . ( ".dels") the Click (function () { $ (.. "Check:. the checked") Parents (. "TRS") Remove (); }) }) <Table> <TR> <TD> <INPUT type = "checkbox" class = " checkAll"> Select All </ td> <td> merchandise </ td> <td> Price </ td> <td> number </ td> <td> Total </ td> < td> operation </ td> </tr> <tr class="trs"> <td><input type="checkbox" class="check" checked></td> <td>青少年读物</td> <td class="price">¥12.60</td> <td><a class="reduce">-</a><input type="text" class="num" value="1"><a class="add">+</a></td> <td class="count">¥12.60</td> <td class="delete"><em class="del">删除</em></td> </tr> <tr class="trs"> <td><input type="checkbox" class="check"></td> <td>情感书籍</td> <td class="price">¥24.80</td> <td><a class="reduce">-</a><input type="text" class="num" value="1"><a class="add">+</a></td> <td class="count">¥24.80</td> <td class="delete"><em class="del">删除</em></td> <div class =" ZJ "> </tr> <tr class="trs"> <td><input type="checkbox" class="check" checked></td> <td>心理读物</td> <td class="price">¥2.10</td> <td><a class="reduce">-</a><input type="text" class="num" value="2"><a class="add">+</a></td> <td class="count">¥4.20</td> <td class="delete"><em class="del">删除</em></td> </tr> <tr> <td><input type="checkbox" class="checkAll">全选</td> <td><em class="dels "> Delete selected merchandise </ EM> </ td> itemsWe have been selected from the <span class = "nums"> <td colspan =" 3 "class =" ZJS "> <td> <EM class =" Removes "> cleanup cart </ EM> </ td> Total: <span class = "Prices"> ¥ 12.60 </ span> </ div> </ td> </ TR> </ the Table>