我试图从span标签内的数字中添加/减去数字。这是一个复选框依赖。这是我想了jQuery:如何使用jquery添加或减去html元素的数字
//If checked
var $newprice = $("#totalprice").val() + 299;
$("#totalprice").text($newprice);
//If NOT checked
var $newprice = $("#totalprice").val() - 299;
$("#totalprice").text($newprice);
如果我选中该复选框,它增加了299,但选中变化数-299。
分享您的HTML代码... –
您需要'parseInt()' – guradio
您能告诉我们一些工作代码吗? @ Garrettj944 – Shrabanee