Jquery shopping cart real-time settlement instance Program

Source: Internet
Author: User

This article will introduce you to a very useful jquery shopping cart real-time settlement instance program, as long as it is used by B2C e-commerce websites, you can achieve fast and no new settlement.

The function code is as follows:

The Code is as follows: Copy code

$ (Function (){
$ (". Child_tab tr: last-child"). find ("td" ).css ({borderBottom: 'none '})
// Obtain the text box object
Var t = $ (". amount-input ");
// Add quantity operation
$ (". Amount-up"). click (function (e ){
Var c1 = parseInt ($ (this). prev (). val ());
$ (This). prev (). val (c1 + 1 );
E. preventDefault ()
SetTotal ();
});
// Quantity reduction operation
$ (". Amount-down"). click (function (e ){
Var c1 = parseInt ($ (this). next (). val ());
If (c1> = 1 ){
$ (This). next (). val (c1-1 );
};
E. preventDefault ()
SetTotal ();
});
Function setTotal (){
// Obtain the value of each condition
Var num1 = $ (". sum1"). text ();
Var num2 = $ (". sum2"). text ();
Var num3 = $ (". sum3"). text ();
Var total = 0;
Var x1 = 4, x2 = 10, x3 = 49;
// Traverse the total number of parts
T. each (function (index, ele ){
Total + = parseInt ($ (ele). val ());
});
$ (". Figure" detail .html (total );
// Determine which quantity meets the requirements
If (total <x2 ){
B2 = num1
} Else if (total> = x2 & total <= x3 ){
B2 = num2
} Else if (total> = x3 ){
B2 = num3
}
$ (". Money" into .html (total * b2). toFixed (2) + 'meta'); // toFixed () is a very useful function to retain the decimal point.
}
// Initialization
SetTotal ();
 
})

The effect is as follows:



Full instance: http://file.bKjia. c0m/upload/2013/09/taobao.rar

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.