appcan 多個列表購物車加減數量例子

來源:互聯網
上載者:User

標籤:多個列表 購物車 加減數量

html代碼如下:

  <div class="uinn4 white" id="listview"> 

   <ul> 

   <!--------列表迴圈---->

    <li class="ubb ub bc-border t-bla ub-ac lis" data-index="0"> 

     <div class="checkbox umar-r"> 

      <input type="checkbox" class="uabs ub-con" /> 

     </div> 

     <ul class="ub ub ub-ver"> 

      <li class=""> 

       <div class="lis-icon ub-img" style="background-image:url(images/shopping_list.png)"></div> 

       <div class="ulev-1 bc-text umar-t"></div></li> 

     </ul> 

     <ul class="ub-f1 ub ub-pj ub-ac"> 

      <ul class="ub-f1 ub ub-ver marg-l"> 

       <li class="bc-text ub ub-ver ut-m line1"><span class="pro_name">聯想筆記本</span><br />規格:<span class="code">Y430P</span><br />積分值:<span class="red jifen">28800</span></li> 

       <li class="ulev-1 sc-text1 uinn3"> 

        <div class="ub ub-ac"> 

         <div class="ub-f1 t-gra3 ulev-3">

           數量 

         </div> 

         <div class="ub ub-f3"> 

          <div class="minus uwh-pSC1 tx-c uba bc-border uc-a-app1 t-bla mar-ar1">

            - 

          </div> 

          <div class="uba uc-a-app1 bc-border uinput uwh-pSC1 mar-ar1 c-wh"> 

           <input value="1" type="text" class="uinn-pSC3 t-bla tx-c" /> 

          </div> 

          <div class="plus uwh-pSC1 tx-c uba bc-border uc-a-app1 t-bla">

            + 

          </div> 

         </div> 

        </div> </li> 

      </ul> 

     </ul></li>

     <!-------列表迴圈結束----->

   </ul>

  </div>



對於這種多個要更改多個input的值,可以用this的值來擷取到相應的input。


加:

$(".plus").click(function(){ 

var t=$(this).parent().find(‘input.tx-c‘); 

t.val(parseInt(t.val())+1); 

//setTotal(); 

}) 


減:

$(".minus").click(function(){ 

var t=$(this).parent().find(‘input.tx-c‘); 

t.val(parseInt(t.val())-1) 

if(parseInt(t.val())<0){ 

t.val(0); 

alert("數量已經是0");

//setTotal(); 

}) 



計算總金額:

/*function setTotal(){ 

var s=0; 

$("#listview li.lis").each(function(){ 

s+=parseInt($(this).find(‘input.tx-c‘).val())*parseFloat($(this).find(‘span.jifen]‘).text()); 

}); 

$("#total").html(s.toFixed(2)); 

setTotal(); 


appcan 多個列表購物車加減數量例子

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.