In JavaScript, Strings are immutable.
All types except objects define immutable values. Specifically, strings are immutable (unlike in C for instance).
So, str.replace returns a new string. Try this instead:
CSS_Left = CSS_Left.replace('px', '');
Or if you don't want to overwrite the original string, just do it in the alert
call
alert(CSS_Left.replace('px', ''));
It's worth noting that .replace
can also take a regexp. Though it's not necessary in your case, you could do something like this to achieve the same result
CSS_Left = CSS_left.replace(/px$/, '');