首頁  >  工具  > $.isNumeric(value)

返回值:Boolean jQuery.isNumeric(value)

概述

確定它的參數是否是一個數字。

$.isNumeric() 方法檢查它的參數是否代表一個數值。如果是這樣,它返回 true。否則,它返回false。該參數可以是任何型別的

參數

value V1.7

用於測試的值。

示例

描述:

Sample return values of $.isNumeric with various inputs.

jQuery 程式碼:


$.isNumeric("-10");  // true
$.isNumeric(16);     // true
$.isNumeric(0xFF);   // true
$.isNumeric("0xFF"); // true
$.isNumeric("8e5");  // true (exponential notation string)
$.isNumeric(3.1415); // true
$.isNumeric(+10);    // true
$.isNumeric(0144);   // true (octal integer literal)
$.isNumeric("");     // false
$.isNumeric({});     // false (empty object)
$.isNumeric(NaN);    // false
$.isNumeric(null);   // false
$.isNumeric(true);   // false
$.isNumeric(Infinity); // false
$.isNumeric(undefined); // false