I need to execute a JQuery code when an element’s class attribute is changed. For example, initially the element will be : <div class="my-class">. So, when a new class is added to this div, (i.e. <div class="my-class new-class">, I have to trigger a JQuery code.
How do I do this in JQuery? Is there event for attribute change?
If you have absolutely no means of telling when the external function changes the class (like, a custom event, for example), you will have to do something like this: