title: How to clone a select element of chosen plugin
body: <p>I use the Chosen Plugin for jQuery (found here: <a href="http://harvesthq.github.com/chosen/" rel="nofollow noreferrer">http://harvesthq.github.com/chosen/</a> ). It adds extra functionality to select HTML elements. </p>
  
  <p>I wanted to clone a div that contains a select element and increment all the id.
  The problem is that the clone is ok but the select event apply to the source and not to the clone.</p>
  
  <pre><code>&lt;div id="smallConfig"&gt;  
  &lt;div id="MainConfig_1"&gt;
  
  &lt;select data-placeholder="Choose a country" name="country_1" id="country_1" class="chzn-select"&gt;
  &lt;option value="" /&gt; 
  &lt;option value="Afghanistan"&gt;Allemagne&lt;/option&gt;
  &lt;option value="Afghanistan"&gt;Belgique&lt;/option&gt; 
  &lt;/select&gt;
  
  &lt;input style="vertical-align: middle;" type="text" class="large" name="cni" id="f_1" /&gt;
  
  &lt;span class="f_help"&gt; &lt;/span&gt;
  &lt;a  class="add"&gt;Add more&lt;/a&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;script type="text/javascript"&gt;
  
  var cur_num = 1;    // Counter used previously.
  
  var addAttendee = function(){
  var cloned = $("#MainConfig_" + cur_num).clone(true, true).get(0);
  ++cur_num;
  cloned.id = "MainConfig_" + cur_num;                  // Change the div itself.
  $(cloned).find("*").each(function(index, element) {   // And all inner elements.
      if(element.id)
      {
          var matches = element.id.match(/(.+)_\d+/);
          if(matches &amp;&amp; matches.length &gt;= 2)            // Captures start at [1].
              element.id = matches[1] + "_" + cur_num;
      }
  });
  $(cloned).appendTo($("#smallConfig"));
  };
  
  $('.add').click(addAttendee); // attach event
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I found this thread <a href="https://stackoverflow.com/questions/10523395/how-to-add-chosen-plugin-to-dynamically-created-cloned-css-div">How to add Chosen Plugin to dynamically created / cloned CSS div?</a> but i'm not able to adapt to my code.</p>