I am seeking a method to dynamically change the CSS rules of an imported stylesheet within my document. The external stylesheet contains various classes and div attributes, and I aim to modify one of these rules using JavaScript or jQuery.
For example:
.red{
color:red;
}
The goal is to use JavaScript to inform the HTML that the color property in the rule should be changed to something else, like this:
.red{
color:purple;
}
Furthermore, I want this updated rule to apply to any new elements added through appending. So if I insert a span
with the CSS class .red
, its text should appear purple instead of red.
I hope my explanation is clear.