Been trying to convert the following to number:
Although this is an old post, I thought that a simple function can make the code more readable and keeps with jQuery chaining code-style:
String.prototype.toNum = function(){
return parseInt(this, 10);
}
can be used with jQuery:
var padding_top = $('#some_div').css('padding-top'); //string: "10px"
var padding_top = $('#some_div').css('padding-top').toNum(); //number: 10`
or with any String
object:
"123".toNum(); //123 (number)`