title: Check browser width after resize, without reload (Javascript)
body: <p>I have a small piece of Javascript that checks what the browser's width is on load and, depending on the result, runs a piece of jQuery. This to display a different menu on mobile devices </p>
  
  <p>However, it CAN happen a user starts with a very small browser on his desktop, running the jQuery (and therefore the mobile menu). If he then resizes to full-screen, the menu doesn't change, because the check on the browser's width doesn't run again.</p>
  
  <p>The question: How do I adapt the Javascript so it checks every time the browser is resized?</p>
  
  <p>My code:</p>
  
  <pre><code>if (window.innerWidth &lt;= 992) {
      jQuery(document).ready(function($) {
          $(".main-menu").hide();
          $(".mobile-nav-button").click(function() {
              $(".main-menu").slideToggle(500);
          });
      });
  }
  else {
      jQuery(document).ready(function($) {
          $(".mobile-nav-button").hide();
          $(".mobile-cart-button").hide();
      });
  }
  </code></pre>