phil crowe phil crowe - 1 year ago 82
jQuery Question

trim "px" off the end of Jquery var

I have a variable which stores the css value of a margin. I want to remove the "px" from the end so that i just have the number to work with. How can i do this?

Answer Source
var x = "1px";
var y = parseInt(x, 10); // specify radix to prevent unpredictable behavior
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download