亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

購物車全選以及計(jì)算金額

Original 2019-06-25 00:43:03 323
abstract:$(function(){    //初始化     doPrice()// 鼠標(biāo)移上全選框變色效果 $('.fa-check').mouseover(function(){   if($(this).attr('class')!='fa fa-check checked'){   &nbs

$(function(){
   //初始化
    doPrice()
// 鼠標(biāo)移上全選框變色效果
$('.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() //其實(shí)這里還可以使用別的參數(shù)獲取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)計(jì)所有勾選的值
function doPrice(){
 var items=$('.list-item i[class*="fa-check"]')
 var checkeditems=$('.list-item i[class$="checked"]').parents('.select').siblings('.good-total-price')//選中小計(jì)的價(jià)錢
 var totalprice=0//儲(chǔ)存總計(jì)
 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)
 
}

//刪除當(dāng)前商品
$('.operation').click(function(){
   $(this).parents('.list-item').remove()
})




})

Correcting teacher:查無此人Correction time:2019-06-25 17:50:19
Teacher's summary:完成的不錯(cuò)。每行js和jq語句結(jié)束增加;號(hào)。繼續(xù)加油

Release Notes

Popular Entries