jQuery.isNumeric()


jQuery.isNumeric( value )返回值: 布尔值版本弃用: 3.3

描述: 判断其参数是否表示 JavaScript 数字。

注意: 此 API 已在 jQuery 3.3 中弃用。

$.isNumeric() 方法检查其参数是否表示数值。如果是,则返回 true。否则返回 false。参数可以是任何类型。

从 jQuery 3.0 开始,$.isNumeric() 仅在参数类型为 number 或类型为 string 且可以强制转换为有限数字时返回 true。在所有其他情况下,它返回 false

示例

$.isNumeric 使用各种输入的示例返回值。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// true (numeric)
$.isNumeric( "-10" )
$.isNumeric( "0" )
$.isNumeric( 0xFF )
$.isNumeric( "0xFF" )
$.isNumeric( "8e5" )
$.isNumeric( "3.1415" )
$.isNumeric( +10 )
$.isNumeric( 0144 )
// false (non-numeric)
$.isNumeric( "-0x42" )
$.isNumeric( "7.2acdgs" )
$.isNumeric( "" )
$.isNumeric( {} )
$.isNumeric( NaN )
$.isNumeric( null )
$.isNumeric( true )
$.isNumeric( Infinity )
$.isNumeric( undefined )