i want to execute a function when开发者_C百科 the element 's class updated (any new class add or remove).
how i can do this in jQuery
You'll need to set up a custom event.
//function to receive event
$('#foo').bind('class_change', function() {
alert("Class changed");
});
//use trigger() to fire custom event
$('#foo').addClass("newClass").trigger('class_change');
$('#foo').removeClass("newClass").trigger('class_change');
精彩评论