【发布时间】:2014-04-28 17:20:07
【问题描述】:
我在任务栏中有一个“开始”按钮。将鼠标悬停在它上面会显示更多选项(登录、注册、注销)。为了您的方便,我还创建了一个(简化的)JSFiddle:http://jsfiddle.net/wF43d/4/
//1. bind mouseenter / mouseleave to imitate ".hover()":
$('#start').bind({
mouseenter: function(e)
{//some other positioning code goes here
$slider.show();
},
mouseleave: function(e)
{
$slider.hide();
}
});
问题是我无法用鼠标访问这些进一步的选项,因为一旦我将鼠标悬停在“开始”之外,尽管使用了 .unbind(),这些选项就会消失,但显然是错误的:
$('#logout').on({
mouseenter: function(){
$('#start').unbind(); //this is supposed to unbind 1. but it doesn't!!!
} //more code goes here
(JSFiddle 中的第 29 行代码)。
我知道我可以简单地包含更多选项(“.start_options”)作为“.taskbar”的相对定位的子元素,并为它们设置动画以滑出任务栏的左侧;但是,任务栏的“overflow-y:scroll;”属性阻止了这种情况,由于某种原因,它也阻止了“overflow-x”。
因此,我完全定位了更多选项,并在将鼠标悬停在“开始”按钮上时显示它们,但是如何在“#start”的悬停(JSFiddle 中的“mouseleave”)时防止/取消绑定它们被隐藏“?
非常感谢!
【问题讨论】:
标签: jquery hover mouseenter unbind