Clone and keeping the bound event and changing attributes in the cloned elements
<p>I am attempting to use the .clone() in jquery. I have a $.post retuning an id number i want to change in the cloned element. Is How do I use the .data if i'm cloning parents and children to change the id attribute? i also have an update bound to the select tag I want to keep after cloning.</p>

<p>HTML:</p>

<pre><code>  &lt;div id="basicinfobox"&gt;
   &lt;table id="ethnicitytable"&gt;
     &lt;tbody&gt;
       &lt;tr valign="top"&gt;
         &lt;td&gt;
           &lt;img id="Ethnicity" ref="6" rel="ActorEthnicity" src="plussm.png"&gt;
         &lt;/td&gt;
         &lt;td id="ethnicity22"&gt;
           &lt;select id="22" rel="ActorEthnicity" name="Ethnicity"&gt;
            &lt;option value=""&gt;Ethnicity&lt;/option&gt;
            &lt;option value="Caribbean"&gt;Caribbean&lt;/option&gt;
           &lt;/select&gt;
           &lt;img id="22" border="0" width="16" height="16" onclick="ethnicitydelete(this.id)" alt="Delete Ethnicity" src="deletessm.png"&gt;
          &lt;/td&gt;
     &lt;/tr&gt;
   &lt;/tbody&gt;
  &lt;/table&gt;
 &lt;/div&gt;
</code></pre>

<p>Jquery:</p>

<pre><code>$('#basicinfobox img[src*="plus"]').click(function(){
    var rel=$(this).attr('rel');
    alert(rel)
    var ref=$(this).attr('ref');
    alert(ref);
    //$('#ethnicitytable tr td:last').clone().appendTo('#ethnicitytable tr:last');
    $.post('add.php', {rel: rel}, function(id){
        var elem = $('#ethnicitytable tr td:last')[0];
                clone = elem.clone( true );
        jQuery.data(clone, "id", id);
        clone.appendTo('#ethnicitytable tr:last');
        //$('#ethnicitytable td:last').attr('id', 'ethnicity'+id);
        //$('#ethnicitytable select:last').attr('id', id);
        //$('#ethnicitytable img[src="deletessm.png"]:last').attr('id', id);
    })
})
</code></pre>
