Realization of the function of Mobile mall shopping cart with jquery

Source: Internet
Author: User

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

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.