:
jquery to achieve the shopping cart digital plus and minus effect, the method is simple.
Often write to the shopping cart this piece, and shopping cart is a lot of add and subtract this effect (can copy the HTML code multiple, while supporting), a small summary, the code is as follows:
Html:
<div class= "Gw_num" > <em class= "Jian" >-</em> <input type= "text" value= "1" class= "num"/ > <em class= "Add" >+</em></div>
Css:
. gw_num{border:1px solid #dbdbdb; width:110px;line-height:26px;overflow:hidden;}. Gw_num em{display:block;height:26px;width:26px;float:left;color: #7A7979, border-right:1px solid #dbdbdb; text-align : Center;cursor:pointer;}. Gw_num. Num{display:block;float:left;text-align:center;width:52px;font-style:normal;font-size:14px;line-height: 24px;border:0;}. Gw_num em.add{float:right;border-right:0;border-left:1px solid #dbdbdb;}
Jquery:
$ (document). Ready (function () {//Add the effect $ (". Add"). Click (function () { var n=$ (this). Prev (). Val (); var num=parseint (n) +1; if (num==0) {return;} $ (this). Prev (). val (num); }); Minus effect $ (". Jian"). Click (function () { var n=$ (this). Next (). Val (); var num=parseint (n)-1; if (num==0) {return} $ (this). Next (). Val (num); });
});
jquery realizes the digital plus and minus effect of shopping cart