Last active
November 1, 2018 09:52
-
-
Save stevenwadejr/6125219 to your computer and use it in GitHub Desktop.
Sometimes I want to execute some custom code while chaining on a jQuery element and maintain that chainability.
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
$.fn.chain = function(func) { | |
func.apply(this); | |
return this; | |
} | |
$('#my-div') | |
.fadeIn() | |
.chain(function(){ | |
// Do something here | |
// You can even use $(this) on your original element | |
}) | |
.fadeOut(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment