. amount-wrap. Icon{Display:Inline-block;width:28px;Height:28px;Line-height:28px;text-align:Center;Border:1px solid #cdcdcd;Background-color:#eee;vertical-align:Middle;}. Amount-wrap. Icon-minus{Border-right:0;}. Amount-wrap. Icon-plus{Border-left:0;}. Amount-wrap input{width:40px;Margin-bottom:0;text-align:Center;vertical-align:Middle;}
<TDclass= "Amount-wrap"><ahref="#"class= "icon Icon-minus"></a><inputtype= "text"value= "1"><ahref="#"class= "icon Icon-plus"></a></TD>
$ (' #orderList '). Find (' input[type= "text"] '). On (' KeyUp paste input ',function(){ This. Value = ~ ~ This. Value.replace (/\d/g, "); if( This. Value = = ") This. Value = 0; Settotal (); }); $(' #selectList '). On (' KeyUp paste input ', ' input[type= "text"] ',function(){ This. Value = ~ ~ This. Value.replace (/\d/g, "); if( This. Value = = ") This. Value = 0; Settotal (); }); $(' #orderList. Minus '). On (' click ',function(e) {e.preventdefault (); varT = $ ( This). Parent (). Find (' input[type= ' text "] '), Tit= $( This). Parents (' Li '). Find (' H2 > A '). HTML (), price= $( This). Parents (' Li '). Find (' Span.order-price > I '). HTML (), PID= $( This). Parents (' Li '). attr (' id ')), Index= $( This). Parents (' Li '). Index (), CATID= $ ('. Swiper-nav '). Find ('. Swiper-slide '). EQ (index). Data (' catid ')), Cattit= $ ('. Swiper-nav '). Find ('. Swiper-slide '). EQ (index). Find ('. Title ')). HTML (), $hasPid= $ ("#selectList"). has (' #s-' +pid); if(parseint (T.val ()) > 0) {t.val (parseint (T.val () )-1); } if($hasPid) {if(parseint (T.val ()) = = 0){ $(' #s-' +pid). Remove (); }Else{ $(' #s-' + pid '). Find (' input[type= ' text "] '). Val (parseint (T.val ())); }} settotal (); }); $(' #orderList. Plus '). On (' click ',function(e) {e.preventdefault (); varT = $ ( This). Parent (). Find (' input[type= ' text "] '), Tit= $( This). Parents (' Li '). Find (' H2 > A '). HTML (), price= $( This). Parents (' Li '). Find (' Span.order-price > I '). HTML (), PID= $( This). Parents (' Li '). attr (' id ')), Index= $( This). Parents ('. Swiper-slide '). Index (), CATID= $ ('. Swiper-nav '). Find ('. Swiper-slide '). EQ (index). Data (' catid ')), Cattit= $ ('. Swiper-nav '). Find ('. Swiper-slide '). EQ (index). Find ('. Title ')). HTML (), $hasPid= $ ("#selectList"). has (' #s-' +pid). length; T.val (parseint (T.val ())+1); if($hasPid) {$ (' #s-' + pid '). Find (' input[type= ' text "] '). Val (parseint (T.val ())); }Else{ var_html = ' <li id= ' s ' +pid+ ' > ' + ' <a href= ' # ' class= ' ' > ' +cattit+ ' ' +tit+ ' </a><span C lass= "Order-price pull-right" >¥<i> ' +price+ ' </i></span> ' + ' <div class= ' Clearfix sele Cted-btm "> ' + ' <a href=" # "class=" Icon-del "></a> " + ' <div class= "Order-amount pull-right" > ' + ' <a href= "#" class= "minus" ></a> ' + ' <input type= "text" value= "' +parseint (T.val ()) + '" > ' + ' <a href= "#" class= "plus" &G T;</a> ' + ' </div> ' + ' </div> ' + ' </li> '; $("#selectList ul"). Append (_html); } settotal (); }); $(' #selectList '). On (' click ', '. Plus ',function(e) {e.preventdefault (); var$ This= $( This), $parentLi= $ This. Parents (' Li '), $pid= $parentLi. attr (' id '). replace (' s ', ' '); varT = $ This. Parent (). Find (' input[type= ' text "] '); T.val (parseint (T.val ())+1); $(' # ' + $pid). Find (' input[type= ' text "] '). Val (T.val ()); Settotal (); }); $(' #selectList '). On (' click ', '. Minus ',function(e) {e.preventdefault (); var$ This= $( This), $parentLi= $ This. Parents (' Li '), $pid= $parentLi. attr (' id '). replace (' s ', ' '); varT = $ This. Parent (). Find (' input[type= ' text "] '); if(parseint (T.val ()) = = 1){ $ This. addclass (' Disable '); return false; } t.val (parseint (T.val ())-1); $(' # ' + $pid). Find (' input[type= ' text "] '). Val (T.val ()); Settotal (); }); $(' #selectList '). On (' click ', '. Icon-del ',function(e) {e.preventdefault (); var$ This= $( This), $parentLi= $ This. Parents (' Li '), $pid= $parentLi. attr (' id '). replace (' s ', ' '); $parentLi. Remove (); $(' # ' + $pid). Find (' input[type= "text"] '). val (0); Settotal (); }); functionsettotal () {varMoneytotal = 0, numtotal = 0; varDate =NewDate (); Date.settime (Date.gettime ()+ (1 * 24 * 60 * 60 * 1000)); $("#orderList Li"). each (function(){ var$ This= $( This), Numval= $ This. Find (' input[type= ' text "] '). Val (), PID= $ This. attr (' id '); if(Numval > 0) {Moneytotal+ = parseint (numval) *parsefloat ($ ( This). Find (' Span.order-price>i '). text ()); Numtotal+=parseint (Numval); $.cookie (Pid,numval,{path:path,expires:date}); $.cookie (' Mtotal ', moneytotal,{path:path,expires:date}); $.cookie (' Ntotal ', numtotal,{path:path,expires:date}); }Else{$.cookie (PID,NULL, {path:path,expires:-1}); } }); if($ ("#selectList ul li"). Length = = 0){ $("#selectList"). Hide (); }Else{ $("#selectList"). Show (); } $("#moneyTotal"). HTML (moneytotal.tofixed (2)); $("#numTotal"). HTML (numtotal); $("#moneyTotal2"). HTML (moneytotal.tofixed (2)); $("#numTotal2"). HTML (numtotal); }
Shopping cart number plus minus code