gpt4 book ai didi

jquery - 当输入框中的值过高时收到警报

转载 作者:行者123 更新时间:2023-12-01 07:18:11 25 4
gpt4 key购买 nike

当用户输入的值大于 1 时,就会出现警报。

这不起作用:

<input id="inputValue" type="text">
$(function () {
$(document).ready(function () {
$('#inputValue').keyup(function () {
if ('#inputValue'.val()) > 1 alert('Value must be a decimal between 0 en 1');

});
});
})(jQuery);

最佳答案

您的代码中有很多错误

试试这个

  $(document).ready(function () {
$('#inputValue').keyup(function () {
if ($(this).val() > 1 )
alert('Value must be a decimal between 0 en 1');
});
});

关于jquery - 当输入框中的值过高时收到警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16935311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com