mouseover()问题上的.slideUp()和slideDown() - 对于每个元素的不同

时间:2014-11-05 15:24:28

标签: jquery hover slidedown slideup

目前的问题是$(".someclass").is(":hover") works well for only single "someclass" instance

的扩展 jquery片段下面的

http://jsfiddle.net/4x661tt6/

的效果非常好
$(document).ready(function() {
  $("body").mousedown(function() {
      if ($(".title").is(":hover") || $(".helper:hover").length ) return;
      $(".helpers").slideUp(); //slideToggle();
  });
  $(".title").mouseover(function() {
    $(".helpers").slideDown();
  });
});

我的下一个问题是让它与http://jsfiddle.net/4x661tt6/1/一起运行(识别文档鼠标点击,排除" .title"" .helper"),此外,标题触发器对slideDown()所拥有的孩子有所不同......

现在,在另一个菜单的源扩展后,悬停在任何" .title" slidesDown()两个实例和后台点击已停止被识别


编辑:我改变了

的返回行
if ($(".title:hover").length || $(".helper:hover").length ) return; //is(":hover")

它现在认识到更多" .title"实例....我想早点挖掘它!

现在唯一的问题是每个" .title"不同,我会在家里

1 个答案:

答案 0 :(得分:0)

is(":hover")仅适用于单个实例。

试试这一点:

$("body").mousedown(function() {
   var isHovered = !!$('.title, .helper').
                filter(function() { return $(this).is(":hover"); }).length;

   if (isHovered)
     return;
  alert( 'triggered' );
});

http://jsfiddle.net/wxfok6mv/1/