Home > Web Front-end > JS Tutorial > jquery shopping cart real-time settlement special effects implementation ideas_jquery

jquery shopping cart real-time settlement special effects implementation ideas_jquery

WBOY
Release: 2016-05-16 17:21:49
Original
1140 people have browsed it
Copy code The code is as follows:

$(function(){
$(".child_tab tr :last-child").find("td").css({borderBottom:'none'})
//Get the text box object
var t = $(".amount-input");
//Amount increase 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( ){
//Get 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 pieces
t.each(function(index,ele){
total =parseInt($(ele).val());
});
$(".figure").html(total );
//Judge which requirement the number meets
if(totalb2=num1
}else if(total>=x2&&total<=x3){
b2= num2
}else if(total>=x3){
b2=num3
}
$(".money").html((total*b2).toFixed(2) '元' );//toFixed() is a function that retains decimal points and is very practical
}
//Initialization
setTotal();

})
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template