教程集 www.jiaochengji.com
教程集 >  jQuery  >  jquery 教程  >  正文 jquery实现购物车实时结算的代码

jquery实现购物车实时结算的代码

发布时间:2015-11-14   编辑:jiaochengji.com
本文介绍下,用jquery代码实现购物车的实时结算效果,一个不错的jquery实例代码,有需要的朋友参考学习下。

如何用jquery实现购物车的实时结算效果呢?
这里分享一例jquery代码,学习下jquery购物车实时结算的方法。

代码:

<script> $(function(){ $(".child_tab tr:last-child").find("td").css({borderBottom:'none'}) //获得文本框对象 var t = $(".amount-input"); //数量增加操作 $(".amount-up").click(function(e){ var c1=parseInt($(this).prev().val()); $(this).prev().val(c1+1); e.preventDefault() setTotal(); }); //数量减少操作 $(".amount-down").click(function(e){ var c1=parseInt($(this).next().val()); if(c1>=1){ $(this).next().val(c1-1); }; e.preventDefault() setTotal(); }); function setTotal(){ //取每个条件的值 var num1=$(".sum1").text(); var num2=$(".sum2").text(); var num3=$(".sum3").text(); var total=0; var x1=4,x2=10,x3=49; //遍历合计件数 t.each(function(index,ele){ total+=parseInt($(ele).val()); }); $(".figure").html(total); //判断个数满足哪个要求 if(total<x2){ b2=num1 }else if(total>=x2&&total<=x3){ b2=num2 }else if(total>=x3){ b2=num3 } $(".money").html((total*b2).toFixed(2)+'元');//toFixed()是保留小数点的函数很实用哦 } //初始化 setTotal(); }) </script>

您可能感兴趣的文章:
jquery实现购物车实时结算的代码
php网上商城购物车代码一例
php 购物车的实现代码一例(session方式)
基于jquery的购物车 jsorder
jquery购物车实时结算特效实现思路
php mysql购物车实现程序
php中cookie mysql实现的购物车代码
php 购物车功能实现代码(入门例子)
php购物车的实现原理
MV* 框架 与 DOM操作为主 JS库 的案例对比

[关闭]
~ ~