変数の内容が数か調べる

変数の内容が数(数値または数字で構成された文字列)か調べる。

alert( jQuery.isNumeric( 1 ) );		// true
alert( jQuery.isNumeric( 1.05 ) );	// true
alert( jQuery.isNumeric( '1' ) );	// true
alert( jQuery.isNumeric( '0xFF' ) );	// true
alert( jQuery.isNumeric( '' ) );	// false
alert( jQuery.isNumeric( 'abc' ) );	// false
alert( jQuery.isNumeric( null ) );	// false

// 参考)isNaN関数
alert( isNaN( 1 ) );		// false
alert( isNaN( 1.05 ) );		// false
alert( isNaN( '1' ) );		// false
alert( isNaN( '0xFF' ) );	// false
alert( isNaN( '' ) );		// false
alert( isNaN( 'abc' ) );	// true
alert( isNaN( null ) );		// false

jQuery.isNumeric関数(1.7以降)はPHPのisNumeric関数と同じく変数が数字か調べるのに対し、isNaN関数は変数がNaN(Not a Number:数値の未定義型)かどうか調べる。