将鼠标悬停在菜单上时如何打开菜单?

时间:2018-09-10 17:28:51

标签: javascript twitter-bootstrap mouseevent drupal-8 collapse

我的网站上有一个折叠的菜单,我希望将其打开以将鼠标悬停在桌面上。

这是我的JS代码,但不起作用:

$(".navbar-toggle-first").mouseenter(function () {
        $(".navbar-collapse-first").fadeIn();
    });
 $(".navbar-toggle-first").mouseleave(function(){
       $(".navbar-collapse-first").fadeOut();
});

这是我页面的HTML代码:

<button type="button" class="navbar-toggle-first collapsed" data-toggle="collapse" data-target="#navbar-collapse-first" aria-expanded="false">

  <div class="icon-navbar-first">
    <span class="fa-layers fa-3x">
      <i class="far fa-circle"></i>
      <span class="navbar-icon-open">
        <i class="fas fa-th-list" data-fa-transform="shrink-8"></i>
      </span>
      <span class="navbar-icon-close">
        <i class="fas fa-times" data-fa-transform="shrink-8"></i>
      </span>
    </span>
  </div>

  <div class="icon-navbar-first-alert icon-navbar-first-alert-disable">
    <span class="fa-layers fa-3x">
      <i class="fas fa-circle"></i>
      <span class="navbar-icon-open">
        <i class="fas fa-th-list fa-inverse" data-fa-transform="shrink-8"></i>
      </span>
      <span class="navbar-icon-close">
        <i class="fas fa-times fa-inverse" data-fa-transform="shrink-8"></i>
      </span>
    </span>
  </div>

</button>

{# Navigation (collapsible first) #}
{% if page.navigation_collapsible_first %}
  <div id="navbar-collapse-first" class="navbar-collapse-first collapse width navbar-collapse-first-fixed-top">
    {{ page.navigation_collapsible_first }}
  </div>
{% endif %}

0 个答案:

没有答案