jQuery.isNumeric()Method

jQuery 杂项方法jQuery Miscellaneous Methods

Examples

Determine the type of input value

$(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 )); })

Try it yourself »

Definition and Usage

The $.isNumeric() function is used to determine whether the specified parameter is a numeric value.

Note:In jQuery 3.0, the $.isNumeric() method returns true only when the parameter is of type number, or is a string type that can be coerced to a finite numeric value; otherwise it returns false.


Syntax

$.isNumeric( value )

Parameter Description
value Any type Any value that needs to be determined.


jQuery 杂项方法jQuery Miscellaneous Methods

Other Extensions