On 11 sep, 09:13, voltron <[EMAIL PROTECTED]> wrote: > How can I access the elements returned when using clone and > manipulate them? I would like to change the Ids of the clone elements > and siblings before appending it to another element. > > Example > > <div id="allcars"> > <div id="carselection"> > <select id="cars"> > <option value ="volvo">Volvo</option> > <option value ="saab">Saab</option> > <option value ="opel">Opel</option> > <option value ="audi">Audi</option> > </select> > </div> > </div> > > JS > > $("#carselection").clone().appendTo("#allcars"); >
Here is an example, you can split it into multiple lines if you want to avoid the .end(), I just like it that way :) There must be 69 other ways to do it.. It will append "_clone" to the id of the element that have an id attribute. --<snip>-- $('#carselection').clone().find("[EMAIL PROTECTED]").andSelf() .each(function() { $(this).attr("id", $(this).attr("id") + '_clone') }).end().end().appendTo('#allcars'); --</snip>-- Regards, Renaud Drousies