html - Change class style (not individual elements) that's not in stylesheet using Javascript -
this question has answer here:
i have series of divs share class assorted reasons (and number of divs created via code @ other points).
i've tried find answers, rely on class being in stylesheet (if there one), doesn't happen in case or alters existing elements instead of rules themselves.
so need like...
var add_to_styles('myclassname'); myclassname.csstext = "color: red;"
and have divs created (both before , after script running) have class
<div class="myclassname">i should red</div>
to come out rule change. haven't found this.
you can add new <style></style>
new rules (new or existing classes) , append body (so read after other stylesheets).
you can target specific parent (and don't modify other existing elements if don't want change of them).
Comments
Post a Comment