jquery wait for element to exist then run ficntion code example
Example: jquery wait for element to exist
var checkExist = setInterval(function() {
if ($('#the-canvas').length) {
console.log("Exists!");
clearInterval(checkExist);
}
}, 100); // check every 100ms