【问题标题】:SuperFish Menu prevent hiding element with a specific classSuperFish Menu 防止隐藏具有特定类的元素
【发布时间】:2014-12-16 06:46:29
【问题描述】:

我有超级鱼菜单,我希望它在所有情况下都按预期运行,除了我有一些我希望始终打开的子菜单项。我给了他们一类 sf-exclude

<ul class="sf-menu">
  <li><a>Parent Item</a>
    <ul> ... </ul> <-- this behaves as expected
  </li>
  <li><a>Parent Item</a>
    <div class="sf-mega">
      <ul class="sf-exclude"> ... </ul> <-- these menu items remain open always but retain sfHover toggle
      <ul class="sf-exclude"> ... </ul>
    </div>
  </li>
</ul>

在我的 JavaScript 中我有这样的东西:

jQuery(".sf-menu").superfish({
  onHide: function() {
    if (this.attr('class') == 'sf-exclude'){return false;} <-- this is not preventing the hide
  }
});

我已经尝试过 onBeforeHide。我已经调整了 CSS 中的所有内容。不知道我做错了什么...有什么建议吗?

【问题讨论】:

    标签: jquery superfish


    【解决方案1】:

    我找到了答案:

    jQuery(".sf-menu").superfish({
      onBeforeHide: function() {
        if (this.attr('class') == 'sf-exclude'){
          this.stop(true,true);
        }
      }
    });
    

    最大的关键是停止执行当前堆栈中的任何 jQuery 动画,但允许进程继续进行,这样我就可以保持添加 sfHover 类等。使用 stop(true,true) 可以做到这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-10
      • 1970-01-01
      • 2014-03-28
      • 1970-01-01
      • 2011-01-24
      • 2016-08-29
      • 2019-12-25
      • 1970-01-01
      相关资源
      最近更新 更多