【问题标题】:mouseenter same item on mouseleave鼠标在鼠标离开时输入相同的项目
【发布时间】:2013-07-17 13:34:37
【问题描述】:

我已经编辑了一个脚本来按我的需要行事..

我需要 #currentitem 来在页面加载时 mouseenter ,当另一个项目触发 mouseenter 时 mouseleave (所以不要重叠)。

我有一个问题,一切都按预期工作。除了当我鼠标离开 #currentitem 时,我需要它的下拉菜单保持可见。所以唯一不可见(或 mouseenter)的时候是当 mouseenter 其他菜单项时。

我创建了一个 JSFiddle,其中当前项目是“关于我们”菜单:

http://jsfiddle.net/qFS84/2/

$(document).ready(function(){
$("#currentitem a").trigger('mouseenter');
});
$(".submenu").mouseenter(function(){
  $("#currentitem").trigger('mouseleave');
});
$(".submenu").mouseleave(function(){
   $("#currentitem a").trigger('mouseenter');
});

任何帮助将不胜感激。

【问题讨论】:

标签: jquery mouseenter mouseleave


【解决方案1】:

我在您的问题上取得了一些进展,希望对您有所帮助。

http://jsfiddle.net/Z2zMz/5/

$('#currentitem').mouseout(function(){
    $("#currentitem > a").trigger('mouseenter');
})

最大的问题是您正在寻找发生在具有 .submenu 类的元素上的事件,但您正在侦听的元素没有 .submenu 类。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-20
    • 1970-01-01
    • 1970-01-01
    • 2012-01-25
    • 2014-02-21
    相关资源
    最近更新 更多