In the val
docs written this description:
.val() Returns: String, Number, Array
I tried to get a Number
, b
You could simply create a jquery plugin to use instead of val() that would do this. Here I create the function nval() to use instead of val() when fetching a elements value.
$.fn.nval = function() {
return Number(this.val())
};
Then in your code just use the following to get the value as a number
$('#elementID').nval()