How to see if a class was added to an element using JavaScript

If you need to see if a class has been added to an element the easiest way is to trigger a new event when you add the class. $(this).addClass(‘someClass’); $(mySelector).trigger(‘cssClassChanged’); The problem with this solution is what happens if you do not have control over the function where this happens. Like if it happens in the WordPress core, and you know that you should never ever change code in the core.

Continue reading...