Number of shopping carts added and reduced
Right Plus
$ (". Jiahao"). Click (function () {
var t = $ (this). Siblings (). Find ("input");//Fetch quantity
t.val (parseint (T.val ()) + 1) ;//parseint () parse input a string, return an integer
heji ();//Call the function evaluated later
})
Left minus sign
$ (". Jianhao"). Click (function () {
var t = $ (this). Siblings (). Find ("input");
T.val (parseint (T.val ())-1);
The minimum value is equal to 1
if (parseint (T.val ()) < 1) {
t.val (1)} When the number is less than 1
;
Heji ();
})
Calculate the total price of a commodity
function Heji () {
$ (". Gwcar"). each (function () {//Cycle whole cart
var oprice =;//Total Price
$ (this). Find (". Glist"). Each item (function () {//Cycle cart), this is worth this shopping cart
if ($ (this). Find (". btn"). Hasclass ("option") = = True) {//To determine if a product is selected , this refers to the three items of the shopping cart
var num = $ (this). Find (". Shuliang"). Val (); In the quantity, this refers to the product of the shopping cart a
var Danjia = $ (this). Find (". Danjia"). Text ();
var Xiaoji = num * DANJIA; Commodity Subtotal
Oprice + = Xiaoji;
$ (". Zongjia"). HTML (oprice);;});};
The last picture is a
The above is a small series to introduce the jquery to realize mobile phone mall shopping cart function, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!