Is there any specific way to execute a JS script until a pop-up element has appeared, without using setTimeout()
? Following are the steps for pop-up opening.
- User is on abc.com and clicks a button.
- Pop-up element appears.
- User clicks on another button in pop-up. The event handler should be specific to this click.
My current implementation is provided below.
$(document).on('click',function() {
window.setTimeout(function() {
if ($('#pop-up').css("visibility") === "visible") {
$('.modal-footer button').click(function() {
// Do something;
}
});
}
},1500);
});