-
-
Save felipepodesta/b6ce488bb050da5f650da922d5e41285 to your computer and use it in GitHub Desktop.
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
| /** | |
| * jQuery afterTime() method is simply setTimeout() function that can be used to chain with jQuery selectors | |
| * @param {ms} sec [the callback will excute after] | |
| * @param {function} callback [the function to excute] | |
| * @return {jQuery selectors} | |
| */ | |
| jQuery.fn.extend({ | |
| afterTime: function (sec, callback) { | |
| that = $(this); | |
| setTimeout(function () { | |
| callback.call(that); | |
| }, sec); | |
| return this; | |
| } | |
| }); | |
| // Sample usage | |
| $(document).ready(function () { | |
| $('#content').append("Dom Ready.<br/>").afterTime(2000, function () { | |
| $(this).append("This will appear after 2 secs.<br/>") | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment