title: jQuery orientation with $(window).resize ooops
body: <p>i am trying to achieve the folowing:
  The website i am working on works better on landscape mode.
  i want that when the device is on Portrait a message is displayed and when on Landscape the message is not displayed.</p>
  
  <p>i have written, inside the ready() function, the following code:</p>
  
  <pre><code>    $(window).resize( function(){
  
      var height = $(window).height();
      var width = $(window).width(); 
  
      if(width&gt;height) {
          // Landscape
          $("#landscape").css('display','none');
      }   
      else {
          // Portrait
          $("#landscape").css('display','block');
          $("#landscape").click(function(){
              $(this).hide();
          });
      }
  </code></pre>
  
  <p>but when the page loads (or i refresh it) it ALWAYS shows the the message (as it should only in portrait mode). If i then change the browser size the code starts working and shows/hides the message accordingly.
  How could i fix this?</p>
  
  <p>Thanks!</p>