jquery按钮控制text文本框商品数量增加或减少
来源:互联网 发布:数控拉料器怎么编程 编辑:程序博客网 时间:2024/04/30 10:15
jquery按钮控制text文本框商品数量增加或减少,加了很多判断,记录一下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link href="http://www.jsfoot.com/skin/css/style.css" type="text/css" rel="stylesheet" /><style type="text/css">*{margin:0;padding:0;}a,img{border:0;text-decoration:none;}body{font:12px/180% Arial, Helvetica, sans-serif, "新宋体";}/* p_number */.p_number{border:solid 1px #ddd;padding:10px 0 0 10px;width:480px;height:80px;margin:40px auto;}.p_number .f_l{float:left;}.p_number .add_chose{width:105px;}.p_number .add_chose a{float:left;margin:5px 0 0 0;display:block;width:15px;height:15px;line-height:99em;overflow:hidden;background:url(http://www.jsfoot.com/jquery/demo/2013-01-05/images/reduce-add.gif) no-repeat;}.p_number .add_chose a.reduce{background-position:0 0;}.p_number .add_chose a.reduce:hover{background-position:0 -16px;}.p_number .add_chose a.add{background-position:-16px 0;}.p_number .add_chose a.add:hover{background-position:-16px -16px;}.p_number .add_chose .text{float:left;margin:0 5px;display:inline;border:solid 1px #ccc;padding:4px 3px 4px 8px;width:40px;line-height:18px;font-size:14px;color:#990000;font-weight:800;}.p_number .buy{line-height:2em;}.p_number .buy .total-font{font-family:Arial;font-size:26px;}.p_number .buy .jifen{margin-left:20px;color:#ACACAC;}.p_number .buy .jifen b{margin:0 3px;}</style><script type="text/javascript" src="jqlx/jquery-1.8.0.js"></script><script>(function($){function shownum(unprice_id,num_id,price_id,jifen_id){this.unprice_id=unprice_id;this.num_id=num_id;this.price_id=price_id;this.jifen_id=jifen_id}shownum.prototype={changeprice:function(){var now_unit= parseInt($("#"+this.unprice_id).text().slice(1));var now_num=$("#"+this.num_id).val();$("#"+this.price_id).text("¥"+now_unit*now_num);$("#"+this.jifen_id).text(now_unit*now_num);}}$(function(){ gouwu(); function gouwu(){ var shownum1=new shownum("price_item_1","qty_item_1","total_item_1","total_points"); shownum1.changeprice(); $(".add").click(function(){ $("#qty_item_1").val(function(index,value){ value++; return value; }); shownum1.changeprice(); }) $("#qty_item_1").keyup(function(e){ if(e.which==38){ $(".reduce").trigger("click")}else if(e.which==40){ $(".add").trigger("click")}else{ if(e.which<48 || e.which>57){ $(this).val(function(index,value){ var len=value.length; return value.replace(/[^0-9]/ig, "");//剔除非数字 });}shownum1.changeprice();} }) $(".reduce").click(function(){ $("#qty_item_1").val(function(index,value){ value--; value=value<0?0:value; return value; }); shownum1.changeprice(); }) }})})(jQuery)</script></head><body><div class="shortcut"><h1><a href="http://www.jsfoot.com/jquery/form/more/2013-01-05/880.html">jquery按钮控制text文本框商品数量增加或减少</a></h1><span class="right"><a href="http://www.jsfoot.com/jquery/form/more/2013-01-05/880.html"><strong>下载特效</strong></a></span><div class="clr"></div></div><!--/ Codrops top bar --><div class="headeline"></div><div class="p_number"><div style="height:36px;font-size:16px;">商品单价:<strong id="price_item_1">¥350.00</strong></div><div class="f_l add_chose"><a class="reduce" href="javascript:void(0)">-</a><input type="text" name="qty_item_1" value="1" id="qty_item_1"class="text" /><a class="add" href="javascript:void(0)">+</a></div><div class="f_l buy">总价:<span class="total-font" id="total_item_1">¥89.00</span><input type="hidden" name="total_price" id="total_price" value="" /><span class="jifen">购买商品可获得:<b id="total_points">18</b>积分</span></div></div><!--演示内容结束--></body></html>
- jquery按钮控制text文本框商品数量增加或减少
- vue2.0+stylus实现商品增加减少控制按钮组件
- jquery来实现的添加商品和减少商品数量
- 商品详情页中的数量的增加与减少
- 仿淘宝购物车demo---增加和减少商品数量
- Flex中单选按钮控制表格中的列的增加或减少
- 带有增加与减少按钮的数量选择控件QuantityView
- 带有增加与减少按钮的数量选择控件QuantityView
- 自定义组件:购买数量,带减少增加按钮
- 实现类似于购物车控制商品数量的按钮
- jquery控制商品数量加减改变价格,只能输入数字
- 文本框实时增加减少数据
- 减少购物车中的商品数量
- jquery来实现的添加商品和减少商品数量,用于购物车等实时改变价格
- 简单封装一个组件:购买数量,带减少增加按钮AmountView
- 类似于购物车,点击按钮,购物数量的增加或者减少
- js——input框实现淘宝一样的点击后商品数量的增加和减少
- 系统消息数量的增加及减少!
- DB2事务日志使用经验
- HDU 1541 Stars
- 进入黑马day3-xml三种解析方法比较
- 进入黑马day3-HTTP协议与tomcat协议
- 奇数在左偶数在右
- jquery按钮控制text文本框商品数量增加或减少
- IOS中Json解析的四种方法
- TabHost的应用(上)------第三日
- Java中基本数据类型和引用型数据类型的区别
- 2013-02-26 新学期的 第一天~~~~~
- GDB调试core文件样例(如何定位Segment fault)
- Qemu 联网问题
- Oracle查询时做条件判断
- [iPhone初级]IOS自带NSXMLParser对xml文件的解析