我的HTML代码如下:
<html>
<SCRIPT type="text/javascript" language="JavaScript">
function fun()
{
var l = document.test.low.value;
var h = document.test.high.value;
alert(l);
alert(h);
if(l >h){
alert("low greater than high low is -"+l+"high is -"+h);
}
}
</SCRIPT>
<body>
<form name="test">
<input type="text" size="11" id="low" />
<input type="text" size="11" id="high" />
<input type="button" value="sss" onClick="fun()"/>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我比较这两个值时,使用low是12而high是112则不起作用.像22和122,33和133等....
我正在使用IE浏览器版本8.请帮助.
所以这是我的代码:
var score1 = $(this).attr('data-score1');
var score2 = $(this).attr('data-score2');
if (score1 < score2) {
// do some
}
if (score2 > score1) {
// do something else
}
Run Code Online (Sandbox Code Playgroud)
现在,只要两个变量都是<或两个> 100都可以正常工作,但是当这两个变量中的任何一个大于100而另一个变量没有错误时if语句被触发.这到底怎么回事?谢谢你的建议!
我的代码中有一个错误,我在这里比较字符串而不是数字。
我正在做“ 100” <“ 5”,并且返回true。
为什么JavaScript认为“ 100”小于“ 5”?