title: Dynamic Javascript when changing screen size
body: <p>I have a div class where I want change the css class name when resolution of the user's screen changes. The following script works:</p>
  
  <pre><code>if ( $(window).width() &lt; 739) {     
    $("#default").toggleClass('classold classnew');
  }
  else {
    $("#default").toggleClass('classold classold');
  }
  </code></pre>
  
  <p>But it has a problem. When I open a browser with a width of 600px and change it to full screen, the mobile class version is not updated. It only works when I reload the page.</p>
  
  <p>How can I make this work without reloading the page?</p>