title: jQuery dynamic element is created but not able to get the handle to dynamic elements
body: <p>In the below code, I am looping through each XML and creating dynamic content. </p>
  
  <pre><code>$('#instDiv').append( "&lt;div&gt;&lt;b&gt;" + 
  $(this).attr('institute') + "&lt;/b&gt;&lt;/div&gt;" + 
  "&lt;div&gt;Type: " + $(this).find('type').text() + 
  "&lt;/div&gt;" + "&lt;div&gt;Name:&lt;/div&gt;" + 
  "&lt;div onClick=\"showDiv('inst"+idCounter+"');\"&gt;&lt;b&gt;" + $(this).find('RM').text() + 
  "&lt;/b&gt;&lt;/div&gt;" + "&lt;span id=\"inst"+idCounter+"\" &gt;" + 
  "&lt;table&gt;&lt;tr&gt;&lt;td rowspan=3&gt;&lt;img height=50 width=40 src='imgurl'&gt;&lt;/img&gt;&lt;/td&gt;&lt;td&gt;Phone#: " + $(this).find('ph').text() + "&lt;/td&gt;&lt;/tr&gt;" + 
  "&lt;tr&gt;&lt;td&gt;Email: " + $(this).find('mail').text() + 
  "&lt;/td&gt;&lt;/tr&gt;" + "&lt;tr&gt;&lt;td&gt;Location: " + $(this).find('loc').text() + 
  "&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/span&gt;" );
  </code></pre>
  
  <p>Calling a <code>showDiv</code> function on click of the name. Creating a span with id as inst &amp; counter.</p>
  
  <p>So for the first element, the id would be <code>inst0</code>. </p>
  
  <p>The <code>showDiv</code> function code is shown below.</p>
  
  <pre><code>function showDiv(divID) {
   alert(divID);
   alert($('#instDiv').html());
   alert($(divID).length);
   $(divID).toggle(); 
  }
  </code></pre>
  
  <p>In the above code, I am able to get the <code>divID</code> value &amp; <code>innerHTML</code> of <code>instDiv</code> also printing the span with the same id.</p>
  
  <p>But, when I try to print that <code>divID</code> length, its returning <strong>0</strong>. Which means, there is no element with that id. In our example the id is <code>inst0</code>. But, this is present in <code>instDiv</code> innerHTML.</p>
  
  <p>How can I get the access to that element. I need to toggle the display on click of the name.</p>