title: Menu that is deleted when I click on a link
body: <p>I would like that when the window is <code>768px</code> or less and if I click on one of the links it will bring me to the right place. Currently, it only goes down but the menu remains open and the cross remains activated.</p>
  <p>I added the last part with the each but it doesn't work properly and makes my menu disappear when I click on a link and in a case where the window is larger than <code>768px</code>.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    resize()
  });
  
  function resize() {
    if (window.innerWidth &gt;= 768) {
      $('.nav__menu').addClass('is-open');
    } else if ($('.nav__menu').hasClass('is-open')) {
      $('.nav__menu').removeClass('is-open');
    }
  
  }
  
  $(window).on('resize', function() {
    resize()
  });
  
  $('.nav__burger').on('click', function() {
    if ($(this).hasClass('is-active')) {
      $(this).removeClass('is-active');
      $('.nav__menu').removeClass('is-open');
    } else {
      $('.nav__menu').addClass('is-open');
      $(this).addClass('is-active');
    }
  });
  
  $('.menu-item').each(function() {
    $(this).click(function() {
      $('.nav__menu').removeClass('is-open')
      $('.nav__burger').removeClass('is-active');
    })
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.header .nav__burger {
    height: 37px;
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    z-index: 2;
    position: absolute;
  }
  
  .header .nav__burger.is-active span {
    background: transparent;
  }
  
  .header .nav__burger.is-active span::before {
    transform: translateY(-2px) rotate(45deg);
  }
  
  .header .nav__burger.is-active span::after {
    transform: rotate(-45deg);
  }
  
  .header .nav__burger span {
    position: relative;
  }
  
  .header .nav__burger span,
  .header .nav__burger span::before,
  .header .nav__burger span::after {
    content: '';
    width: 20px;
    height: 3px;
    background: #000;
    display: block;
    transition: transform 0.5s, background 0.3s;
  }
  
  .header .nav__burger span::after,
  .header .nav__burger span::before {
    position: absolute;
  }
  
  .header .nav__burger span::before {
    transform-origin: 0 50%;
    top: -6px;
  }
  
  .header .nav__burger span::after {
    bottom: -6px;
    transform-origin: 0 50%;
  }
  
  .header .nav__menu {
    z-index: 1;
    display: flex;
    position: fixed;
    background: #e9bf2b;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }
  
  .header .nav__menu a {
    transition: color 0.2s;
    text-decoration: none;
    letter-spacing: 0.07em;
    color: #000;
    text-transform: uppercase;
    font: 700 125% mostra-nuova, sans-serif;
    position: relative;
    display: inline-block;
  }
  
  .header .nav__menu a:after {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 2px;
    background: #952929;
    content: '';
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateY(13px);
  }
  
  .header .nav__menu a:hover::after {
    opacity: 1;
    transform: translateY(3px);
  }
  
  .header .nav__menu&gt;* {
    transform: translateY(-10px);
    transition: transform 0.3s, opacity 0.3s;
    opacity: 0;
  }
  
  .header .nav__menu&gt;*:nth-child(2n) {
    transition-delay: 0.1s;
  }
  
  .header .nav__menu&gt;*:nth-child(3n) {
    transition-delay: 0.1s;
  }
  
  .header .nav__menu&gt;*:nth-child(4n) {
    transition-delay: 0.1s;
  }
  
  .header .nav__menu.is-open {
    opacity: 1;
    pointer-events: auto;
  }
  
  .header .nav__menu.is-open&gt;* {
    opacity: 1;
    transform: translateY(0px);
  }
  
  .header .nav__menu&gt;*+* {
    margin-left: 0;
    margin-top: 40px;
  }
  
  @media (min-width: 768px) {
    .header .nav__burger {
      display: none;
    }
    .header .nav__menu {
      opacity: 0;
      background: none;
      flex-direction: row;
      justify-content: normal;
      align-items: normal;
      position: absolute;
      top: 20px;
      left: 20px;
      bottom: initial;
      right: initial;
    }
    .header .nav__menu a {
      color: #000;
      font-size: 87.5%;
    }
    .header .nav__menu&gt;*+* {
      margin-top: 0;
      margin-left: 30px;
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;section class="header"&gt;
    &lt;div class="container"&gt;
      &lt;button class="nav__burger"&gt;
        &lt;span&gt;&lt;/span&gt;
      &lt;/button&gt;
      &lt;header class="nav"&gt;
        &lt;ul class="nav__menu"&gt;
          &lt;li class="menu-item"&gt;
            &lt;a href="#"&gt;Home&lt;/a&gt;
          &lt;/li&gt;
          &lt;li class="menu-item"&gt;
            &lt;a href="#"&gt;Services&lt;/a&gt;
          &lt;/li&gt;
          &lt;li class="menu-item"&gt;
            &lt;a href="#"&gt;Portfolio&lt;/a&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/header&gt;
    &lt;/div&gt;
  &lt;/section&gt;</code></pre>
  </div>
  </div>
  </p>