title: why is jquery resize not working?
body: <p>I am making a responsive menu. I put the code to change the menu in a function called file.
  when the document or the window are resized Jquery call the function file again to change the menu. but that does not work.
  when I load the page it works but on resize it don't.</p>
  
  <p><strong>Jquery:</strong></p>
  
  <pre><code>var width = $(window).width();
  
  file();
  function file(){
    if(width &lt;= 400){
        $('.link').remove();
        $('head').append('&lt;link class="link" rel="stylesheet" href="nav2.css"&gt;');
    }else if(width &gt;400){
        $('.link').remove();
        $('head').append('&lt;link class="link" rel="stylesheet" href="nav.css"&gt;');
  
    }else{
        alert('error');
    }
  }
  $(window).resize(function(){
    file();
  });
  
  $(document).resize(function(){
    file();
  });
  </code></pre>
  
  <p>can somebody help me with fixing this problem</p>