• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1035
  • Last Modified:

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?
0
sggexchange
Asked:
sggexchange
1 Solution
 
Michel PlungjanIT ExpertCommented:
does not seem to be possible or even a good idea
Why not change className?
0
 
sggexchangeAuthor Commented:
I don't want to use the className approach because I want to change font-size and line-height passing a variable.
0
 
scrathcyboyCommented:
You will have to change the style inline, I don't think you can change the CSS in the <head> with javascript, can you Michel?  Anyway, to change an inline style, it is fairly easy --

document.getElementById('elName').style.display="inline !important";
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Michel PlungjanIT ExpertCommented:
I think you can actually. I do not have a link at hand
0
 
MadestroCommented:
Did anyone ever figured this out?
0
 
David S.Commented:
Did scrathcyboy's suggestion not work for you?
0
 
MadestroCommented:
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.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now