var times_hit = $('#timeshit').val();
if (times_hit > -1 && times_hit < 4 && times_hit != "")
{
if(times_hit == 0)
{
start_score = start_score - parseInt(times_hit.val());;
}
我已经尝试了以上内容。 times_hit是一个等于1的变量。
如果我要做start_score = start_score - 1它可以正常工作。
答案 0 :(得分:0)
您已获得此行的输入值:
var times_hit = $('#timeshit').val();
删除它时,您无需再次致电.val()
。它应该只是:
start_score = start_score - parseInt(times_hit, 10);
或只是
start_score = start_score - times_hit;
因为当你尝试减去它时,字符串会自动转换为数字。