Last active
October 12, 2015 18:30
-
-
Save sarfraznawaz2005/83891289636c21aed95e to your computer and use it in GitHub Desktop.
Add callback to jQuery's CSS method
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
| // Allows you to pass a function to jQuery's 'css' method | |
| // This means you can use the -this- keyword to reference | |
| // the current element!!! | |
| (function($){ | |
| $.fn.oldCSSMethod = $.fn.css; | |
| $.fn.css = function(o) { | |
| return $.isFunction(o) ? | |
| $(this).each(function(){ | |
| $(this).oldCSSMethod(o.call(this)); | |
| }) | |
| : $(this).oldCSSMethod.apply($(this), arguments); | |
| } | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment