title: add remove class in resize window using jQuery
body: <p>I have this jQuery code for <code>add</code> <code>remove</code> class using <code>jQuery</code> in resize window:</p>
  
  <p>JS:</p>
  
  <pre><code>$(function () {
  
      $(window).bind("resize", function () {
          console.log($(this).width())
          if ($(this).width() &lt; 500) {
              $('div').removeClass('yellow').addClass('red')
          } else {
              $('div').removeClass('red').addClass('yellow')
          }
      })
  })
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div style="width:300px; height:100px;" class="yellow"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>In action, This worked only when i manualy resize window But in default if device window &lt; 500 this function not work. </p>
  
  <p>how do fix this ?!</p>
  
  <p>Demo <a href="http://jsfiddle.net/6v7GE/" rel="nofollow">HERE</a></p>