jQuery on class removing event

html, jquery

Solution

There is no such event. But you can do simpler:

$('div').live('click', function(){
    $(this).toggleClass("underline")
    if ($(this).hasClass("underline")) {
        alert("added");
    } else {
        alert("removed");
    }
});​

DEMO: https://jsfiddle.net/VYukS/1/

Problem

Well, I got something like this: HTML: ``` <div id="main" class="underline" >Hello</div> ``` JavaScript: ``` $('div').live('click', function(){ $(this).toggleClass("underline"); });​ ``` https://jsfiddle.net/VYukS/ I have to run some function on event when div class was removed, and I haven't got any permisions to edit functions that adding / removing class from div. How can I catch that event when class is removing? 'click' event was used only as an example, so that class can be removen not only on the clicking

Original source

Related problems