title: Window onload function is not working properly?
body: <p>This is my code :</p>
  
  <p>I have used window onload function to populate ui elements but it is not working properly. </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Regalo - Shop&lt;/title&gt;
  &lt;link rel="stylesheet" href="&lt;%=request.getContextPath()%&gt;/resources/css/bootstrap.min.css" /&gt;
  &lt;script src="&lt;%=request.getContextPath()%&gt;/resources/js/jquery-1.9.1.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
  $(window).on('load',function(){
      alert("OK");
      &lt;c:forEach var="item" items="${itemList}"&gt;
  
              var name= '${item.desktopbrand}';
              var details='${item.details}';
              var id = '${item.desktopid}';
              var price = '${item.desktopid}';
              var catagory = '${item.catagory}';          
  
      var spanTag = '&lt;div class="col-sm-6 col-md-4"&gt; &lt;div class="thumbnail"&gt; &lt;img data-src="img/Desktop/'+ id +'.jpg"&gt; &lt;div class="caption"&gt;&lt;h3&gt;'+ name+ '&lt;/h3&gt; &lt;p&gt;'+ price+ '&lt;/div&gt; &lt;/p&gt; &lt;p&gt;&lt;button type="button" class="btn btn-success btn-lg" onclick="details()"&gt;Show Details&lt;/button&gt;&lt;/p&gt;&lt;p&gt;&lt;button type="button" class="btn btn-success btn-lg" onclick="addToCart()"&gt;Buy now&lt;/button&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;';
      $("#" + catagory).append(spanTag);
          &lt;/c:forEach&gt;
      });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Gens Cooner&lt;/h1&gt;
      &lt;div id="gen" class="container"&gt;&lt;/div&gt;
      &lt;h1&gt;Ladies Cooner&lt;/h1&gt;
      &lt;div id="lad" class="container"&gt;&lt;/div&gt;
      &lt;h1&gt;Childrens Cooner&lt;/h1&gt;
      &lt;div id="chil" class="container"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I try to find the issue but couldn't. Your help would be highly appreciated.</p>