gpt4 book ai didi

javascript - jQuery/JavaScript : Subtract current 'value' till 'Zero'

转载 作者:行者123 更新时间:2023-12-01 00:52:58 26 4
gpt4 key购买 nike

这是一个简单的;假设我有一个从数据库中提取值的脚本,每次用户单击一个按钮时,该值都会减少一个计数,我该如何防止该值减少到零以下,

 if(count>0){
$.post(sessionStorage.server, { count:count ,request:"counter",user:sessionStorage.sname });
}

if(count==0){
alert("Your value is now zero");
sessionStorage.clear();
sessionStorage.msg="Logged off, ran out of clicks";
window.location.href = "../index.html";
}

最佳答案

试试这个

if(count==0){
alert("Your value is now zero");
sessionStorage.clear();
sessionStorage.msg="Logged off, ran out of clicks";
window.location.href = "../index.html";
}
else if(count>0){
$.post(sessionStorage.server, { count:count ,request:"counter",user:sessionStorage.sname });
}

关于javascript - jQuery/JavaScript : Subtract current 'value' till 'Zero' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13640112/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com