If it were in the form of .95 instead of 95%, you could use parseFloat(string) instead.
The main troubles with eval are a long run time and the possibility of evaluating malicious strings entered by a user.
MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
...as long as the string is always a valid CSS property; "95px", "95%" "95pt" etc; you shouldn't need to use eval atall. You're eval-ing putting quotes around the value of a var; so the eval will return an object of type string; the var in that example is already a string, growing suspense... conclusion : the eval does _nothing_. Some kind of property parser gets invoked when you assign a string to a CSS property via script - it will parse the string 95%.
MattEvans
Veteran Poster
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64