你如何比较jQuery的值与固定数字?
我认为这可能有用,但它没有:
if (parseInt($("#days").value) > 7) {
alert("more than one week");
}
Run Code Online (Sandbox Code Playgroud)
除了@redsquare的使用答案外.val()
,您还应指定基数:
if (parseInt($("#days").val(), 10) > 7) {
alert("more than one week");
}
Run Code Online (Sandbox Code Playgroud)
这是因为该值可能具有前导0,在这种情况下parseInt
将该值解释为八进制.
归档时间: |
|
查看次数: |
6370 次 |
最近记录: |