title: Run function when element is loaded
body: <p>A few things I've read have led me to the <code>ready()</code> function, but that seems to run as soon as the document itself is ready, regardless of what element you actually call it on.  For example, I'm used to running things when the page is loaded like this:</p>
  
  <pre><code>$(document).ready(function() {
    window.alert("foo");
  });
  </code></pre>
  
  <p>What I'm trying to do is run a script when an element with a certain is loaded.  That element is added to the page dynamically, and not when the page is initially loaded.  I've tried this:</p>
  
  <pre><code>$("#element-id").ready(function() {
    window.alert("foo");
  });
  </code></pre>
  
  <p>But that runs on page load, regardless of what id I pass in.  Whether or not an element with the passed in id exists on the page or not, or is loaded dynamically, the function always runs on page load, and never again.</p>
  
  <p>How do I tell jquery to run a function when an element is loaded? I'm using jQuery 2.1.4.</p>