title: Running jQuery inside $(window).load() function but not inside $(document).ready function
body: <p>I have this existing function that will icons in a web page using jQuery UI position plugin:</p>
  
  <pre><code>&lt;script type='text/javascript'&gt;
  jQuery( document ).ready( function( $ ) {
  var element_selector='.test';
  if ( $(element_selector).length !== 0) {
  
  //jQuery UI Position code here
  
  }
  
   });
  &lt;/script&gt;
  </code></pre>
  
  <p>This function is found near the footer section of the HTML although in some places it outputs on the head section. Someone suggested me to load this jQuery inside $(window).load() function. The reason is that $(document).ready event is fired when DOM is loaded, so it’s fired when the document structure is ready, but before images are loaded.</p>
  
  <p>$(window).load() event is fired after whole content is loaded. So .position() method might not calculate correct position when it’s fired to early (before images are loaded). </p>
  
  <p>If this true, how to revise the above load in $(window).load(). Thanks.</p>
  
  <p><strong>UPDATE</strong>: I have changed from:</p>
  
  <pre><code>jQuery( document ).ready( function( $ ) {
  </code></pre>
  
  <p>To this:</p>
  
  <pre><code>jQuery(window).load(function($) {
  </code></pre>
  
  <p>And I get this error in the console:</p>
  
  <pre><code>Uncaught TypeError: object is not a function 
  </code></pre>
  
  <p>It fails on this line:</p>
  
  <pre><code>$(divname515e62e8355b0).children().wrapAll('&lt;div class="mydoc cf"&gt;');
  </code></pre>
  
  <p>where  divname515e62e8355b0 is the selector define here:</p>
  
  <pre><code>var divname515e62e8355b0 = '#test_selector';
  </code></pre>