title: Get id's div with dynamic generation of divs
body: <p>Let's say I have :</p>
  
  <pre><code>&lt;div id="form"&gt;
      &lt;div id="form_field1_0"&gt;
          &lt;div id="form_field1_0_att1"&gt;&lt;/div&gt;
          &lt;div id="form_field1_0_att2"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div id="form_field1_1"&gt;
          &lt;div id="form_field1_1_att1"&gt;&lt;/div&gt;
          &lt;div id="form_field1_1_att2"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div id="form_field1_0"&gt;
          &lt;div id="form_field1_2_att1"&gt;&lt;/div&gt;
          &lt;div id="form_field1_2_att2"&gt;&lt;/div&gt;
      &lt;/div&gt;
      //...
  &lt;/div&gt;
  </code></pre>
  
  <p>And I have a Javascript function which add as many <code>#form_field1_n</code> as the user wants.</p>
  
  <p>And now, I want a <code>change()</code> call for each <code>#form_field1_</code>n<code>_att1</code>.</p>
  
  <p>How would you do that ?</p>
  
  <p>Here is the Javascript which add divs (with my id's div):</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function() {
          var $container = $('div#mybundle_serveur_typesDetails');
          var $addLink = $('&lt;a href="#" id="add_type" class=""&gt;Ajouter un type&lt;/a&gt;');
          $container.append($addLink);
          $addLink.click(function(e) {
              addSource($container);
              e.preventDefault(); // évite qu'un # apparaisse dans l'URL
              return false;
          });
  
          var index = $container.find(':input').length;
  
          if (index == 0) {
              addSource($container);
          } else {
              $container.children('div').each(function() {
                  addDeleteLink($(this));
              });
          }
  
          function addSource($container) {
              var $prototype = $($container.attr('data-prototype').replace(/__name__label__/g, 'type n°' + (index+1))
                  .replace(/__name__/g, index));
  
              addDeleteLink($prototype);
  
              $container.append($prototype);
              index++;
          }
  
          function addDeleteLink($prototype) {
              $deleteLink = $('&lt;a href="#" class="btn btn-danger"&gt;Supprimer&lt;/a&gt;');
  
              $prototype.append($deleteLink);
  
              $deleteLink.click(function(e) {
                  $prototype.remove();
                  e.preventDefault(); // évite qu'un # apparaisse dans l'URL
                  return false;
              });
          }
      });
  &lt;/script&gt;
  </code></pre>