title: Wait to for loop finish job
body: <p>I try to make table with code, but something not going well.</p>
  
  <p>I have array in witch i generate code  for part of table:</p>
  
  <pre><code>List.push("&lt;tr&gt;&lt;td colspan=\"5\"&gt;");
  
  for (k = 0; k &lt; finalList.length; k++) {
      List.push(finalList[k]);
  }
  List.push("&lt;/td&gt;&lt;/tr&gt;");
  </code></pre>
  
  <p>On the end i append it to table like:</p>
  
  <pre><code>$("#commentTable tbody").append(List);
  </code></pre>
  
  <p>Lets say that in array <code>finalList</code> I have divs with images inside.
  for example
  images in multiple divs for example :
      
      </p>
  
  <p>When i run code and use inspect element code is generated like</p>
  
  <pre><code>&lt;tr&gt;&lt;td colspan="5"&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;div&gt;&lt;img src="1.jpg" /&gt;&lt;/div&gt;
      &lt;div&gt;&lt;img src="2.jpg" /&gt;&lt;/div&gt;
  </code></pre>
  
  <p>etc...</p>
  
  <p>Like it is work async and working for while it is line <code>List.push("&lt;/td&gt;&lt;/tr&gt;");</code> finish.</p>
  
  <p>I hope i was clear. That i can do to resolve this?</p>
  
  <p>Thanx</p>