Skip to content

Instantly share code, notes, and snippets.

@mt3o
Created April 28, 2013 12:05
Show Gist options
  • Save mt3o/5476695 to your computer and use it in GitHub Desktop.
Save mt3o/5476695 to your computer and use it in GitHub Desktop.
Attach event before and after class change with jquery
(function(){
// Your base, I'm in it!
var originalAddClassMethod = jQuery.fn.addClass;
jQuery.fn.addClass = function(){
jQuery(this).trigger('beforeCssClassChanged');
var result = originalAddClassMethod.apply( this, arguments );
jQuery(this).trigger('afterCssClassChanged');
// return the original result
return result;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment