Created
June 29, 2017 09:43
-
-
Save ekwoster/30e55fb5f9ae170eedfe258430fd09ec to your computer and use it in GitHub Desktop.
jQuery Class Changed Event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var originalAddClassMethod = jQuery.fn.addClass; | |
var originalRemoveClassMethod = jQuery.fn.removeClass; | |
jQuery.fn.addClass = function(){ | |
var result = originalAddClassMethod.apply( this, arguments ); | |
jQuery(this).trigger('classChanged'); | |
return result; | |
} | |
jQuery.fn.removeClass = function(){ | |
var result = originalRemoveClassMethod.apply( this, arguments ); | |
jQuery(this).trigger('classChanged'); | |
return result; | |
} | |
})(); |
Does this work with :
$element[0].classList.add('my-class');
EDIT : Yes it does ! Thank you 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was very helpful for me today. Thanks!