title: onload and Jquery ready(). Do they work on any DOM? such as table or div?
body: <p>I need to put a dynamic content on a div using javascript script. This div is on the top of the page so it will load first before other things below it. And there are really lot's of things down there. So, when I put the script on the ready() or onload, the div will be empty for 2 -3 seconds while other things are displayed. So, I tried putting the onload or ready() to this div.</p>
  
  <pre><code>//example div, which is on the header part of the page
  &lt;div id="cont1"&gt;
  something goes here
  &lt;/div&gt;
  //... and there are a lot of other things going down here.
  </code></pre>
  
  <p>I tried putting the <code>onload="alert('test')"</code> on the div tag</p>
  
  <pre><code>&lt;div id="cont1" onload="alert('test')"&gt;
  </code></pre>
  
  <p>and also the jquery method</p>
  
  <pre><code>&lt;script&gt;
  $("cont1").ready(function(){
      alert("test");
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Both methods don't work, as the alert is triggered only after the whole page is displayed.</p>
  
  <p>but if I put the <code>alert("test");</code> script immediately after closing the above div, it works fine (as the other things on the page is not displayed yet when the alert is showing). </p>
  
  <pre><code>&lt;div id="cont1"&gt;
  something goes here
  &lt;/div&gt;
  &lt;script&gt;
      alert("test");
  &lt;/script&gt;
  </code></pre>
  
  <p>But this method is kind of a bad design isn't it? So, any other way to achieve this?</p>