Hide div element with jQuery, when mouse isn't moving for a period of time? Hide div element with jQuery, when mouse isn't moving for a period of time? jquery jquery

Hide div element with jQuery, when mouse isn't moving for a period of time?


Take a look at the mousemove event. You can try something like this:

var i = null;$("#element").mousemove(function() {    clearTimeout(i);    $("#menu").show();    i = setTimeout(function () {        $("#menu").hide();    }, 10000);}).mouseleave(function() {    clearTimeout(i);    $("#menu").hide();  });

Demo: http://jsfiddle.net/AMn9v/6/