小白教程
所有教程
关于
Search
172.70.100.189
172.70.100.189
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Misc isnumeric”的源代码
本页内容
上一节:
Misc_isfunction
下一节:
Misc_isplainobject
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:$.isNumeric()}}[[Category:jquery ref misc|23]] = jQuery.isNumeric()方法 = [[jquery ref misc|jQuery 杂项方法]] 判断输入值类型 <sample title="" desc="" lang="html" hererun="1"> $(function () { function fun( html ){ document.body.innerHTML += "<br>" + html; } // true fun($.isNumeric( "-10" )); fun($.isNumeric( "0" )); fun($.isNumeric( 0xFF )); fun($.isNumeric( "0xFF" )); fun($.isNumeric( "8e5" )); fun($.isNumeric( "3.1415" )); fun($.isNumeric( +10 )); fun($.isNumeric( 0144 )); //false fun($.isNumeric( "-0x42" )); fun($.isNumeric( "7.2acdgs" )); fun($.isNumeric( "" )); fun($.isNumeric( {} )); fun($.isNumeric( NaN )); fun($.isNumeric( null )); fun($.isNumeric( true )); fun($.isNumeric( Infinity )); fun($.isNumeric( undefined )); }) </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script> </head> <body> <script> $(function () { function fun( html ){ document.body.innerHTML += "<br>" + html; } // true fun($.isNumeric( "-10" )); fun($.isNumeric( "0" )); fun($.isNumeric( 0xFF )); fun($.isNumeric( "0xFF" )); fun($.isNumeric( "8e5" )); fun($.isNumeric( "3.1415" )); fun($.isNumeric( +10 )); fun($.isNumeric( 0144 )); //false fun($.isNumeric( "-0x42" )); fun($.isNumeric( "7.2acdgs" )); fun($.isNumeric( "" )); fun($.isNumeric( {} )); fun($.isNumeric( NaN )); fun($.isNumeric( null )); fun($.isNumeric( true )); fun($.isNumeric( Infinity )); fun($.isNumeric( undefined )); }) </script> </body> </html> </run> == 定义和用法 == $.isNumeric() 函数用于判断指定参数是否是一个数字值。 '''注意:'''在jQuery 3.0中,$.isNumeric()方法只有接收number类型的参数,或者是可以被强制为有限数值的 string类型的参数时,才会返回true,否则返回false。 == 语法 == $.isNumeric( value ) {| class="table table-striped table-hover" ! 参数 ! 描述 |- | value | 任意类型 需要进行判断的任意值。 |} [[jquery ref misc|jQuery 杂项方法]]
返回至“
Misc isnumeric
”。
上一节:
Misc_isfunction
下一节:
Misc_isplainobject