views:

146

answers:

3

I know jQuery has a helper method for parsing unit strings into numbers. What is the jQuery method to do this?

var a = "20px";
var b = 20;
var c = $.parseMethod(a) + b;
+2  A: 
 var c = parseInt(a,10);
unomi
+6  A: 

No jQuery required for this, Plain Ol' JS (tm) will do ya,

parseInt(a, 10);
Andy E
Everyday in everyway Im loving you more and more javascript
James Westgate
A: 
$.parseMethod = function (s)
{
    return Number(s.replace(/px$/, ''));
};

although how is this related to jQuery, I don't know

just somebody