I'm attempting to perform a function after an element ID becomes visible on a page. I want to make it so that when an element with the ID #discountbox becomes visible, then peform this function.
This is the javascript I've created so far:
jQuery(document).ready(checkContainer);
function checkContainer () {
if($('#discountbox').is(':visible'))){ //if the container is visible on the page
$("#discountbox").clone().insertAfter(".discount-summary");
} else {
setTimeout(checkContainer, 50); //wait 50 ms, then try again
}
}
Unfortunately, this does not appear to be working.