Chinaunix首页 | 论坛 | 博客
  • 博客访问: 307866
  • 博文数量: 128
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1611
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-19 11:49
文章分类

全部博文(128)

文章存档

2018年(2)

2016年(2)

2014年(10)

2013年(114)

我的朋友

分类: Web开发

2013-09-24 09:33:56


点击(此处)折叠或打开

  1. $(function(){
  2. $(".child_tab tr:last-child").find("td").css({borderBottom:'none'})
  3. //获得文本框对象
  4. var t = $(".amount-input");
  5. //数量增加操作
  6. $(".amount-up").click(function(e){
  7. var c1=parseInt($(this).prev().val());
  8. $(this).prev().val(c1+1);
  9. e.preventDefault()
  10. setTotal();
  11. });
  12. //数量减少操作
  13. $(".amount-down").click(function(e){
  14. var c1=parseInt($(this).next().val());
  15. if(c1>=1){
  16. $(this).next().val(c1-1);
  17. };
  18. e.preventDefault()
  19. setTotal();
  20. });
  21. function setTotal(){
  22. //取每个条件的值
  23. var num1=$(".sum1").text();
  24. var num2=$(".sum2").text();
  25. var num3=$(".sum3").text();
  26. var total=0;
  27. var x1=4,x2=10,x3=49;
  28. //遍历合计件数
  29. t.each(function(index,ele){
  30. total+=parseInt($(ele).val());
  31. });
  32. $(".figure").html(total);
  33. //判断个数满足哪个要求
  34. if(total<x2){
  35. b2=num1
  36. }else if(total>=x2&&total<=x3){
  37. b2=num2
  38. }else if(total>=x3){
  39. b2=num3
  40. }
  41. $(".money").html((total*b2).toFixed(2)+'元');//toFixed()是保留小数点的函数很实用哦
  42. }
  43. //初始化
  44. setTotal();

  45. })

阅读(471) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~