I have a broadcasting video site, with a menu, which should be hidden, when mouse isn't moving for a while (lets say 10 seconds). As well, it should appears back, with mouse move. What is the best way to perform that, by using css and jQuery? Thank you in advance.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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/