Shopping cart number plus minus right plus
1 $ (". Jiahao"). Click (function () {2 var t = $ (this). Siblings (). Find ("input");//Fetch quantity 3 t.val (parseint (T.val ()) + 1),//parseint () parse input a string, return an integer 4 Heji ();//Call the function computed later 5 })
Left minus sign
1 $ (". Jianhao"). Click (function () {2 var t = $ (this). Siblings (). Find ("input"); 3 t.val (parseint (T.val ())-1); 4 //When the number is less than 1 let the minimum be equal to 15 < 1 ) {6 t.val (1)7 }; 8 Heji (); 9 })
Calculate Total Product Price
1 function Heji () {2 $ (". Gwcar"). each (function () {//cycle the entire shopping cart3 var oprice = 0;//commodity price4 $ (this). The Find (". Glist"). each (function () {///cycle shopping cart for each item, this is worth this shopping cart5 if ($ (this). Find (". btn"). Hasclass ("option1") = = True) {//To determine if the product is selected, this is the three items of the shopping cart6 var num = $ (this). Find (". Shuliang"). Val ();//Fetch quantity, this refers to the product of a shopping cart7 var Danjia = $ (this). Find (". Danjia"). Text ();8 var xiaoji = num * DANJIA;// Subtotal9 Oprice + = Xiaoji;Ten $ (". Zongjia"). HTML (oprice); One }; A }); - }); -};
A final picture of the drawings
Using jquery to implement Mobile Mall shopping cart function