I need to 'decorate' every div.myclass with a function in a way that css is doing it with style, that is some of these elements aren't on a page when this function fires, so I can't just find and loop trough them. Some of the elements are created from ajax requests, and some are changing classes.
In css when an element changes class it's style changes instantly. I also need a similar situation here when for example all divs with class1 would have declared one function and with class2 another, and when I do for example:
document.getElementsByClassName("class1")[0].setAttribute("class", "class2");
Behavior of that element should change instantly.
I prefer pure js, but if it's there a cleaner jquery or prototype way I also be glad.