title: if ($(window).width() < 768) {} not working when browser resizes. How do I fix this?
body: <p>I'm trying to make it so that only when the browser is less than 768px, my navigation bar items will toggle hidden or shown when an element with "navlogo" is clicked. I know I'm not the most descriptive, but here's my code.</p>
  
  <pre><code>if ($(window).width() &lt; 768) {
  
      $(".navlogo").click( function (){
          $(".navwrapper").toggle();
      });
      $(".navitem").click( function (){
          $(".navwrapper").hide();
     });
  
  }
  </code></pre>
  
  <p>I know this is actually going to get marked as a duplicate but it's not. The thing is that I want it to be able to even work without refreshing. If it requires Angular.js then it would be helpful to know what code to use for that because I wouldn't mind using it but yeah I just want for the user to not have to refresh every time to get the correct result. </p>
  
  <p>Also, one bug that happens when I don't have the</p>
  
  <pre><code>if ($(window).width() &lt; 768) {}
  </code></pre>
  
  <p>is that yes it still works properly but even if the website is not in mobile mode, which occurs when the max width is 768px or lower, when the user clicks the element with "navlogo," it still hides the "navwrapper." That's not bad but the thing is that I also want it to hide when a user clicks on an element with "navitem."</p>
  
  <p>Thank you!</p>