Link to home
Start Free TrialLog in
Avatar of sggexchange
sggexchangeFlag for United States of America

asked on

javascript set a style as !important without relying in changing the className

How can I set a style as "!important" using javascript without relying in changing the className and doing it that way?
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

does not seem to be possible or even a good idea
Why not change className?
Avatar of sggexchange

ASKER

I don't want to use the className approach because I want to change font-size and line-height passing a variable.
ASKER CERTIFIED SOLUTION
Avatar of scrathcyboy
scrathcyboy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think you can actually. I do not have a link at hand
Avatar of Madestro
Madestro

Did anyone ever figured this out?
Did scrathcyboy's suggestion not work for you?
I found a way to do this. Use the cssText property of objects. For instance:

myElement.cssText = "inline !important";

cssText allows you to set a whole string with the style.