alert(Tag); // Tag shows it is set to 0 (ZERO) which is less than 10.
if ( Tag < 10) { alert("adding.."); Tag=Tag+10; }
else { alert("Fail"); }
alert(Tag);
//警报显示“失败” //并且警报显示“0”
所以,它说它是零,如果语句没有显示它小于 10, 它仍然为零....我做错了什么??
最佳答案
这在 Tag 实际上是数字 0 时有效。
<script>
var Tag = 0;
alert(Tag); // Tag shows it is set to 0 (ZERO) which is less than 10.
if ( Tag < 10) { alert("adding.."); Tag=Tag+10; }
else { alert("Fail"); }
alert(Tag);
</script>
您在哪里为 Tag 赋值?
关于javascript - 为什么我会遇到 Javascript "if"失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32894276/