jQuery如何检查输入的数字是否大于99 [英] Jquery how to check if a input has a number higher then 99
本文介绍了jQuery如何检查输入的数字是否大于99的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
想知道如何使用jquery检查输入是否包含大于99的数字
Was wanting to know how to check using jquery if a input contains a number higher then 99
推荐答案
尝试一下:
if(parseInt($("selector").val()) > 99) {
/*if it is*/
}
或者如果您正在更改时进行检查:
or if you are checking it on change:
$("selector").change(function(){
if(parseInt(this.value) > 99){
/*if it is*/
}
})
编辑,如下面的评论所述,最好使用parseFloat
而不是parseInt
来比较数字
Edit as said in the below comments, it might be better to use parseFloat
instead of parseInt
to compare the numbers
这篇关于jQuery如何检查输入的数字是否大于99的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文