过儿5年前
$(function(){
//鼠标移上变色
$('.fa-check-square').mouseover(function(){
if($(this).attr('class')!='fa fa-check-square checked'){
$(this).css('color','#ff6700');
}
})
$('.fa-check-square').mouseleave(function(){
$(this).css('color','#fff');
})
//单选中效果
$('.fa-check-square').click(function(){
var cla=$(this).attr('class');
if(cla!='fa fa-check-square checked'){
$(this).attr('class','fa fa-check-square checked');
}else{
$(this).attr('class','fa fa-check-square');
}
checkAll();
})
//全选效果
$('#select_all').click(function(){
var cla=$(this).attr('class');
if(cla!='fa fa-check-square checked'){
$('.fa-check-square').attr('class','fa fa-check-square checked');
}else{
$('.fa-check-square').attr('class','fa fa-check-square');
}
})
//检查是否全选
function checkAll(){
var allitem=$('.list_item span[class*="fa-check-square"]').length;
var checkeditem=$('.list_item span[class$="checked"]').length;
if(allitem!=checkeditem){
$('#select_all').attr('class','fa fa-check-square');
}else{
$('#select_all').attr('class','fa fa-check-square checked');
}
}
//实现加法
$('.add').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 per_price=$(this).parents('.cal_num').siblings('.per_price').children('p').html();
var per_price=parseFloat(per_price);
var total_price=per_price*currentvalue;
$(this).parents('.cal_num').siblings('.total_price').children('p').html(total_price+'元');
})
//实现剪法
$('.sub').click(function(){
var nowvalue=$(this).siblings('input').val();
var nowvalue=parseInt(nowvalue);
var currentvalue=nowvalue;
if(currentvalue>1){
currentvalue=nowvalue-1;
}else{
currentvalue=1;
}
$(this).siblings('input').val(currentvalue);
var per_price=$(this).parents('.cal_num').siblings('.per_price').children('p').html();
var per_price=parseFloat(per_price);
var total_price=per_price*currentvalue;
$(this).parents('.cal_num').siblings('.total_price').children('p').html(total_price+'元');
})
})
0