title: jquery if statement based on screen size
body: <p>I have a slide out nav bar that I would like open by default on screen width of >=1024 and closed by default &lt; 1024. I have a button that toggles it open and closed it. I'm just starting to learn js. I imagine there's a way to set a default toggle state in an if statement if the window width is >=1024. Any help would be greatly appreciated.  Here's what I have so far for the toggle.</p>
  
  <pre><code>$('a.expand').toggle(function() {
          $(this).addClass("open");
          $('#nav').animate({width: 50},{queue:false, duration:300});
          $('.wrapify').animate({marginLeft: 50},{queue:false, duration:300});
          $('.primarynav ul').hide();
          $('.navlogo').hide();   
  
    }, function() {
          $(this).removeClass("open");
          $('#nav').animate({width: 200},{queue:false, duration:300});
          $('.wrapify').animate({marginLeft: 200},{queue:false, duration:300});
          $('.primarynav ul').show();
          $('.navlogo').show(); 
  
    });
  </code></pre>