jQuery菜单切换按钮

时间:2018-10-23 13:00:18

标签: jquery

这是我创建的下拉菜单的脚本。我想在单击链接以关闭下拉菜单时添加。有什么想法吗?

$(document).ready(function() {
  $(".menu-icon").on("click", function() {
    $("nav ul").toggleClass("showing");
  });
});
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<nav>
  <div class="menu-icon">
    <i class="fa fa-bars" style="font-size:36px"></i>
  </div>
  <div class="logo">
    LOGO
  </div>
  <div class="menu">
    <ul>
      <li><a href="#Home">Home</a></li>
      <li><a href="#ourTeam">Our Team</a></li>
      <li><a href="#imageGallery">imageGallery</a></li>
    </ul>
  </div>
</nav>

<style>
  .showing {
        max-height: 34em;
  }
<style>

1 个答案:

答案 0 :(得分:0)

bridgeEndpoint

这有效。小提琴: https://jsfiddle.net/kpxnejLf/1/