<div class="current"></div>
<a href="#">text</a>
How do I detect when e.g. a .live
class is added to this <div>
and do something when it happened?
For example, if class is changed, then hide the link.
I have a minified script that makes changes on the <div>
's class. It’s too big for me to find the place where it happens, so I'm searching for some way to catch the class change.
I don't know if the class you add to the link is always the same but if so, why don't you use CSS for this.
If you just need to figure this out once (i.e. not in code), Google Chrome’s web inspector shows DOM changes live. Not sure if that’d help your situation out though.
You may checkout the following article for some ideas.
There are DOM events, but they are far from perfect and not available in most browsers. In other words: Not possible (reliably). There are hacks like intervals and checking it in each iteration, but if you need to do something like this, your design is probably screwed. Keep in mind that such things will be slow and that there will always be a delay. The smaller the delay, the slower the application. Do not do that.