Skip to content

Instantly share code, notes, and snippets.

@tieutantan
Forked from chrisjhoughton/wait-el.js
Last active November 11, 2020 16:31
Show Gist options
  • Save tieutantan/4f5244208af199fd12ede8926c18a185 to your computer and use it in GitHub Desktop.
Save tieutantan/4f5244208af199fd12ede8926c18a185 to your computer and use it in GitHub Desktop.
Wait for an element to exist on the page with jQuery
// Convert shop the look pricing (EURO only) to cart currency
var existGetTheLook = setInterval(function () {
if ($('.stl__presentmentPrice').length) {
clearInterval(existGetTheLook);
let price_needed = 'data-currency-' + cart_currency.toLocaleLowerCase();
$('span[class="stl__presentmentPrice"]').each(function (index, item) {
let price_by_currency = $(item).attr(price_needed);
$(item).children('.price').html(price_by_currency + ' ' + cart_currency);
});
}
}, 100); // check every 100ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment