有没有办法使用jQuery检查值是否高于300?我已经制作了下面的脚本,但我不知道如何检查该值是否高于300.
$(document).ready(function(){
$("input").on('keyup', function() {
if( $(this).val() == '300' ) {
alert("Stop it now! You're above the 300 mark! I told you to stop, you dum dum!");
}
});
});

<input type="text">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
&#13;
提前致谢!
答案 0 :(得分:-1)
将值解析为int。
$(document).ready(function(){
$("input").on('keyup', function() {
if( Number($(this).val()) > 300 ) {
alert("Stop it now! You're above the 300 mark, damn it! I told you to stop, you dum dum!");
} else {
//Hide your div here
$("#ElementID").hide();
}
});
});