dynamic resizing with jquery
<p>I've seen another reference to this but I can't understand the response.
I am trying to change the height of a page element (#maincontent) dynamically as the window is re-sized.</p>

<p>This is my code:</p>

<pre><code>$(function() {
   if($(window).resize()){
      var h1 = $(window).height();
      var h2 = $('#maincontent').height();
      if (h2&lt;h1){
          $('#maincontent').css('height',h1);
      }
   }
});
</code></pre>

<p>It doesn't work without a page refresh and I can't understand why not. Where have I gone wrong?</p>
