Skip to content

Instantly share code, notes, and snippets.

@theKAKAN
Last active September 9, 2018 17:27
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 theKAKAN/28b658acb64d41b18597bd71151a32b9 to your computer and use it in GitHub Desktop.
Save theKAKAN/28b658acb64d41b18597bd71151a32b9 to your computer and use it in GitHub Desktop.
Wait for element
var waitForEl = function (selector, callback) {
jQuery.when(jQuery(selector)).then(callback);
}
// Example for adding an item to cart
// in Amazon
var element = '#add-to-cart-button';
waitForEl(element, function (self) {
self.trigger('click');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment