referencing dynamically loaded things from a previously loaded jquery script
<p>let's say that i have something like this:</p>

<pre><code>&lt;head&gt;&lt;script src="script1.js" ...&gt;&lt;/script&gt;&lt;/head&gt;
&lt;body&gt;&lt;div id="div1"&gt;&lt;/div&gt;&lt;/body&gt;
</code></pre>

<p>which i call index.html, and div1's content is loaded dynamically, like</p>

<pre><code>$("#div1").html ("div1.html");
</code></pre>

<p>where div1.html is something like</p>

<pre><code>&lt;div id="div2"&gt;&lt;canvas id="canv1" ... /&gt;&lt;/div&gt;
</code></pre>

<p>and i want to reference canv1 somehow in script1.js; by just operating on $("#canv1") nothing happens because script1.js is loaded <strong>before</strong> div1.html; is there a way (e.g. $(document).on(...)) to "do something as soon as [..] is loaded"? i tried</p>

<pre><code>$(document).on ("load", "#canv1", ...);
</code></pre>

<p>but it doesn't work. it's worth noticing that $(document).on ("click", "#canv1", ...) works, but it's not what i want (as in, i want to draw something in the canvas before caring of what happens on click...); any ideas?</p>
