admin管理员组

文章数量:1201992

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.

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.

Share Improve this question edited Nov 30, 2010 at 13:39 karim79 343k67 gold badges417 silver badges407 bronze badges asked Nov 29, 2010 at 16:24 MaayMaay 5751 gold badge9 silver badges28 bronze badges 1
  • Do you get mouse move events when the mouse moves over the video? Or are you using a plugin which stops all of those events bubbling up? If you can't best to use whatever plugin (I'm assuming Flash) is showing the video to handle the menu too. – Douglas Commented Nov 29, 2010 at 16:40
Add a comment  | 

1 Answer 1

Reset to default 26

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/

本文标签: