You can modify style rules, but it's usually not the best design decision.
To access the style rules defined by style sheets, you access the document.styleSheets
collection. Each entry in that collection will have a property either called cssRules
or rules
depending on the browser. Each of those will be a CSSRule
instance. You can change the rule by changing its cssText
property.
But again, that's probably not the best way to solve the problem. But it is the literal answer to your question.
The best way to solve the problem is probably to have another class in your stylesheet that overrides the settings of the previous rule, and then to add that class either to the select
elements or to the container of them. So for instance, you could have the rules:
.fool select {
display: block;
}
.fool.bar select {
display: none;
}
...and when you want to hide the selects, add the "bar"
class to the container that has the "fool"
class.
Alternately, apply CSS style information directly to elements.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…