1
I am creating a system and I need that if the mouse is stopped for 3 seconds on a div do some actions, I had to investigate and found a code, it is working normally but it is generating error in the console whenever the user moves the mouse, although this error does not cause problems to the functioning of the site, someone could help me to remove this error?
PS: The function setEvent()
is also called when there is an Hover on the div I mentioned above
Error:
Uncaught Referenceerror: timeout is not defined
Code:
$(document).on('mousemove', function() {
if (timeout !== null) {
$(".video_overlays").css("display", "block");
$(".trailer").css("cursor", "auto");
clearTimeout(timeout);
}
setEvent();
});
function setEvent(){
timeout = setTimeout(function() {
$(".video_overlays").fadeOut(2000);
$(".trailer").css("cursor", "none");
}, 3000);
}
Just to be sure: rat is the mouse, correct?
– neves
Yes mouse is mouse, I’m pt so that’s what I say mouse
– Tomás