jQuery.isNumeric () method
Examples
Determine the input value type
$ (Function () {
function fun ( html ) {
.. document body innerHTML + = " <br>" + html;}
// True
fun ($. isNumeric ( "-10" )); Fun ($ isNumeric ( . "0" )); Fun ($ isNumeric ( . 0x FF )); 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 ));})
try it"
Definition and Usage
$ .isNumeric () Function is used to determine whether the specified parameter is a numeric value.
Note: In jQuery 3.0 in, $ isNumeric () method only receives a parameter of type number, or can be forced to a limited value of string type parameter, it will return true, otherwise returns false.
grammar
$.isNumeric( value )
参数 | 描述 |
---|---|
value | 任意类型 需要进行判断的任意值。 |