title: jQuery to show/hide dynamic elements
body: <p>I want to hide/show the <code>ul</code> element when I click on the <code>h3</code> tag.  I tried some examples, maybe I am missing something.</p>
  
  <p>My sample code:</p>
  
  <pre><code>$('#gallery').append('&lt;h3 id="' + idx + '" &gt;' + item.title._content + '&lt;/h3&gt;&lt;ul style="display:none;" class="photos grp' + idx + '"&gt;&lt;/ul&gt;');
  
  $('h3#'+idx).click(function () {
     $(this).next('.photos.grp'+idx).toggle();
  });
  </code></pre>