title: Get ID of div created by jquery
body: <p>I have two functions, where the first creates a div in the dom and the second gets the ID via <code>getElementById()</code>. Unfortunately, my second function is just returning null.  </p>
  
  <p>I looked in using <code>$.Deffered()</code> in either of my functions, but alas nothing I do seems to work</p>
  
  <pre><code>function one() {
      var dynamicDiv = $("&lt;div&gt;").attr("id", 'test');
      dynamicDiv.iziModal({
          //modal content here
      })
  }
  
  function two() {
      var container = document.getElementById('test');
      console.log(container.innerHTML); //not returning any data
  
  }
  
  
  enter code here
  </code></pre>
  
  <p>I had hoped to use this with a library that replaces images with a canvas object, but it requires that the "parent element to be a valid DOM Element". I have been searching for a while now, but I can not seem to find anything on the subject that is applicable.</p>
  
  <p>** Edit**
  Thank you for pointing out the error in my id (I had tried something else before I pasted). The iziModal function (<a href="http://izimodal.marcelodolza.com/" rel="nofollow noreferrer">http://izimodal.marcelodolza.com/</a>) is currently pulling the content in via ajax (which I assume is the problem here):</p>
  
  <p>The iziModal Function:</p>
  
  <pre><code>dynamicDiv.iziModal({
          title: '',
          autoOpen: 1,
          width: 500,
          onOpening: function (offer) {
              offer.startLoading();
              $.get(demoUrl, function (data) {
                  $('#' + id + " .iziModal-content").html(data);
                  offer.stopLoading();
              });
          }
      });
  </code></pre>
  
  <p>Content of the other file:</p>
  
  <pre><code>&lt;div id="test"&gt;
      &lt;img src="./bundle/images/coupon.jpg" /&gt;
  &lt;/div&gt;
  </code></pre>