jQuery(document).ready(function() { checkContainer(); }); function checkContainer () { if($('#divIDer').is(':visible'))){ //if the container is visible on the page createGrid(); //Adds a grid to the html } else { setTimeout(checkContainer, 50); //wait 50 ms, then try again } }