Created
March 26, 2019 10:31
-
-
Save DevShahidul/248995582d097165d4ef021a2bfd44de to your computer and use it in GitHub Desktop.
See the example here >>> https://stackoverflow.com/questions/14567990/how-to-add-a-callback-function-to-the-addclass-method-of-jquery
This file contains 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
// Extend jQuery addClass function to accept callback function | |
var oAddClass = $.fn.addClass; | |
var oRemoveClass = $.fn.removeClass; | |
$.fn.addClass = function () { | |
for (var i in arguments) { | |
var arg = arguments[i]; | |
if ( !! (arg && arg.constructor && arg.call && arg.apply)) { | |
arg(); | |
delete arg; | |
} | |
} | |
return oAddClass.apply(this, arguments); | |
} | |
$.fn.removeClass = function () { | |
for (var i in arguments) { | |
var arg = arguments[i]; | |
if ( !! (arg && arg.constructor && arg.call && arg.apply)) { | |
arg(); | |
delete arg; | |
} | |
} | |
return oRemoveClass.apply(this, arguments); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment