Skip to content

Instantly share code, notes, and snippets.

@drakulaboy
Forked from chrisjhoughton/wait-el.js
Created April 9, 2017 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drakulaboy/d4abdf912efee665b7fe8f5503a7bbbd to your computer and use it in GitHub Desktop.
Save drakulaboy/d4abdf912efee665b7fe8f5503a7bbbd to your computer and use it in GitHub Desktop.
Wait for an element to exist on the page with jQuery
var waitForEl = function(selector, callback) {
if (jQuery(selector).length) {
callback();
} else {
setTimeout(function() {
waitForEl(selector, callback);
}, 100);
}
};
waitForEl(selector, function() {
// work the magic
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment