使用MUI框架实现JQ购物车增减

// 购物车数量减少
$('.reduce').click(function () {

addMinus(this,0)
});

// 购物车数量增加
$('.increase').click(function () {

addMinus(this,1)
});

function addMinus(t,state) {
var num=$(t).parent('.select_num').find('.num');
var msg='';
if(state==0){
msg = "宝贝不能再减少了哦"
if (num.text() <= 1) {
mui.alert(msg, "提示");
}else {
num.text(parseInt(num.text())-1)
}
}else if(state ==1){
msg = "宝贝不能再增加了哦"
if (num.text() >= 10) {
mui.alert(msg, "提示");
}else {
num.text(parseInt(num.text())+1)
}
}
}
posted @ 2019-07-02 15:02  文衫-  阅读(831)  评论(0编辑  收藏  举报