event when adding element into document
<p>Adding new html string into the page:</p>

<pre><code>document.getElementById('container').innerHTML = '&lt;div id="child"&gt;&lt;/div&gt;';
</code></pre>

<p>Is there an event that let me know when <code>child</code> element is in the document?</p>

<p>I have a function, which return some html codeas a string. And when this html will be added in the document, I need to execute javascript function. I've tried to use inline <code>onload</code> event</p>

<pre><code>document.getElementById('container').innerHTML = '&lt;div id="child" onload="console.log(\'ready!\');"&gt;&lt;/div&gt;';
</code></pre>

<p>but it does not seem to work.</p>

<p><strong>UPDATE:</strong>
Probably, I should provide more details about the situation. I have a library function</p>

<pre><code>myLibrary.getHtml()
</code></pre>

<p>In old version, users just call this function and append the result into the document:</p>

<pre><code>document.getElementById('container').innerHTML = myLibrary.getHtml();
</code></pre>

<p>In new version, the result is not a plain html. Now users can interact with it after they append it in the document. So after they append html into the document, I need to go through the result DOM and attach event handlers, hide some elements and other things. That is why, I need to know when they add it in the document and execute a javascript function, which turn plain html into fancy interactive widget.</p>
