Is there a way to change an attribute of a CSS class using javascript?
<style type="text/css">
.fool select {
display: block;
}
</style>
<p class="fool">
<select id="a" onchange="changeCSS()"> ... </select>
<select id="b" > ... </select>
<select id="c" > ... </select>
</p>
I want to change display:block to display:none for ALL <select> elements after a user call function changeCSS().
It looks simple but I can’t find a way to do this…
The key is to define extra rules for additional classes and add these classes to the elements rather than to rewrite the rules for a given style rule.
JS
CSS
Or for a really efficient method (but which might need a few more specific style rules too)
JS
CSS