jquery realizes mobile end mobile phone Mall shopping cart function _jquery

Source: Internet
Author: User

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!

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.