gpt4 book ai didi

jquery - 使用 Jquery 测试字符串是否为 Integer

转载 作者:太空狗 更新时间:2023-10-29 15:11:16 25 4
gpt4 key购买 nike

测试字符串是否为整数的函数是什么,就像方法一样:

jQuery.isNumeric()

我想测试输入的 html 元素:

<input id='distance' type='text' />

提前谢谢你

最佳答案

感谢您的贡献,我找到了答案:

if(Math.floor($('#distance').val()) == $('#distance').val() && $.isNumeric($('#distance').val()))
{
alert('yes its an int!');
}

关于jquery - 使用 Jquery 测试字符串是否为 Integer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25788900/

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