国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

統(tǒng)計購物車所以勾選商品的總價

Original 2019-08-09 13:05:20 432
abstract:$(function(){    //初始化     doPrice()// 鼠標移上全選框變色效果 $('.fa-check').mouseover(function(){   if($(this).attr('class')!='fa fa-check checked'

$(function(){

    //初始化

     doPrice()

// 鼠標移上全選框變色效果

 $('.fa-check').mouseover(function(){

   if($(this).attr('class')!='fa fa-check checked'){

    $(this).css('color','#ff6700')

   }

 })

$('.fa-check').mouseleave(function(){

    $(this).css('color','#fff')

 })

//普通選擇

$('.fa-check').click(function(){

  var cla=$(this).attr('class')

  if(cla!='fa fa-check checked'){

    $(this).attr('class','fa fa-check checked')

  }else{

     $(this).attr('class','fa fa-check')

  }

  doCheckAll()

   doPrice()

 })


// 全選選擇


$('#check-all').click(function(){

 var cla=$(this).attr('class')

  if(cla!='fa fa-check checked'){

    $('.fa-check').attr('class','fa fa-check checked')

  }else{

     $('.fa-check').attr('class','fa fa-check')

  }

   doPrice()

})

// 檢查是否全選

 function doCheckAll(){

    var allitem=$('.list-item i[class*="fa-check"]').length

    var checkeditem=$('.list-item i[class$="checked"]').length

    if(allitem!=checkeditem){

        $('#check-all').attr('class','fa fa-check')

    }else{

         $('#check-all').attr('class','fa fa-check checked')

    }



 }

//加減按鈕


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

  var nowvalue=$(this).siblings('input').val()

  var nowvalue=parseInt(nowvalue)

  // var currentvalue=0

  var currentvalue=nowvalue+1

  $(this).siblings('input').val(currentvalue)

  var danjia=parseFloat($(this).parents('.good-num').siblings('.good-price').html())

  var xiaoji=danjia*currentvalue

//頁面中輸出

  $(this).parents('.good-num').siblings('.good-total-price').html(xiaoji+'元')

   doPrice()

})


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

  var nowvalue=$(this).siblings('input').val()

  var nowvalue=parseInt(nowvalue)

  var currentvalue=0

  nowvalue<=1?currentvalue=1:currentvalue=nowvalue-1 

  $(this).siblings('input').val(currentvalue)

 var danjia=parseFloat($(this).parents('.good-num').siblings('.good-price').html())

  var xiaoji=danjia*currentvalue

//頁面中輸出

  $(this).parents('.good-num').siblings('.good-total-price').html(xiaoji+'元')

  doPrice()


})


//統(tǒng)計所有勾選的值

function doPrice(){

  var items=$('.list-item i[class*="fa-check"]')

  var checkeditems=$('.list-item i[class$="checked"]').parents('.select').siblings('.good-total-price')//選中小計的價錢

  var totalprice=0//儲存總計

  for(var i=0;i<checkeditems.length;i++){

   totalprice+=parseFloat(checkeditems[i].innerHTML)

  }

  $('.sum-price').html(totalprice)

  //選中多少件

  $('.select-count').html(checkeditems.length)

  //總商品數(shù)

  $('.all-count').html(items.length)

  

}


//刪除當前商品

$('.operation').click(function(){

    $(this).parents('.list-item').remove()

})





})


Correcting teacher:天蓬老師Correction time:2019-08-15 10:44:31
Teacher's summary:$('.operation').click(function(){ $(this).parents('.list-item').remove() }) jquery 事件 推薦用on()

Release Notes

Popular Entries