John Himmelman John Himmelman - 2 years ago 134
Javascript Question

jQuery / Javascript - How do I convert a pixel value (20px) to a number value (20)

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;

Answer Source

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

parseInt(a, 10);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download