jQuery.isNumeric()Méthode
Exemples
Déterminer le type de la valeur d'entrée
$(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 ));
})
Essayez-le vous-même »
Définition et utilisation
La fonction $.isNumeric() est utilisée pour déterminer si le paramètre spécifié est une valeur numérique.
Remarque :Dans jQuery 3.0, la méthode $.isNumeric() renvoie true uniquement lorsque le paramètre est de type number, ou est de type chaîne pouvant être converti en une valeur numérique finie ; sinon elle renvoie false.
Syntaxe
$.isNumeric( value )
| Paramètre | Description |
|---|---|
| value | Tout type Toute valeur qui doit être déterminée. |
Autres extensions
Méthodes diverses jQuery