I have a div that appears when the user’s mouse leaves the document with a survey about my site.
I don’t want to ask them to do the survey if they move their mouse out in the first couple of minutes while browsing around, so I was wondering if I can set a timeout/sleep on when this mouseleave function would activate.
Here is my code without the timeout:
$(document).mouseleave(function () {
document.getElementById("Overlay1").style.display = "";
});
Thanks a lot!
You can use
window.setTimeoutto enable the function after a certain time.Example: