jQuery.isNumeric()メソッド

jQuery 杂项方法jQuery 雑多メソッド

例

入力値の型を判定する

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

試してみる »

定義と使い方

$.isNumeric() 関数は、指定された引数が数値であるかどうかを判定するために使用されます。

注意:jQuery 3.0 では、$.isNumeric() メソッドは、number 型の引数、または有限の数値に強制変換できる string 型の引数を受け取った場合にのみ true を返し、それ以外の場合は false を返します。


構文

$.isNumeric( value )

パラメータ 説明
value 任意の型 判定が必要な任意の値。


jQuery 杂项方法jQuery 雑多メソッド

その他の拡張