How to delete "px" from 245px

Tomkay picture Tomkay · Feb 1, 2011 · Viewed 63.3k times · Source

Whats a simple way to delete the last two characters of a string?

Answer

Don picture Don · Feb 1, 2011

To convert 245px in 245 just run:

parseInt('245px', 10);

It retains only leading numbers and discards all the rest.