I've got a reference to a CSSStyleRule
object in JavaScript and I want to update the style for border-top-color
to red !important
. If I assign the value red
, no problems occur. If I assign the value red !important
, the value is ignored (i.e. not assigned).
myStyleSheetRule.style.borderTopColor = 'red'; // success
myStyleSheetRule.style.borderTopColor = 'red !important'; // fail
How do I set the !important flag?
Note that it has to be done via a stylesheet rule accessed programatically. In my use case, I can't assign a style attribute or anything else. I'm using Chrome on Windows 7.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…