Similar Question:
Changing a CSS rule-set from Javascript
I am curious to know if it is possible to adjust Css stylesheet declarations without using inline styling.
For instance, consider the following example :
<style>
.box {color:green;}
.box:hover {color:blue;}
</style>
<div class="box">TEXT</div>
This code results in a box with blue text that changes to green on hover.
If I apply inline styling for the color attribute, the hover effect will be lost :
<div class="box" style="color:red;">TEXT</div>
Here, the text in the box will always appear red.
Therefore, my question is how one can access and modify the css declaration object instead of replacing styles with inline ones.
Thank you.