title: Variable Scope outside jQuery function
body: <p>I am trying to identify the height of a div element in HTML, but I am not able to access the value outside of the function.  This is the jQuery:</p>
  
  <pre><code>jQuery.noConflict();
  
  (function($) { 
      $(function() {
          $tmp_cont = $('&lt;div&gt;&lt;/div&gt;');
          $tmp_cont.html($content);
          $tmp_cont.hide();
          $('body').append($tmp_cont);
  
          var $height = $tmp_cont.height();
  
          alert ($height);
      });
  })(jQuery);
  
  alert ($height);
  </code></pre>
  
  <p>The first alert function works, but the second throws and error with <code>$height</code> as undefined. How can I retain the value of <code>$height</code>?</p>