I am looking for some tips on how to solve my problem.
I have a html element (like select box input field) in a table. Now I want to copy the object and generate a new one out of the copy, and that with JavaScript or jQuery. I think this should work somehow but I'm a little bit clueless at the moment.
Something like this (pseudo code):
oldDdl = $("#ddl_1").get();
newDdl = oldDdl;
oldDdl.attr('id', newId);
oldDdl.html();
Try this:
The jQuery way (not the most efficient):
Look at the clone() method of JQuery
Using your code you can do something like that:
In one line:
Yes, you can copy children of one element and paste them into the other element:
Proof: http://jsfiddle.net/de9kc/
It's actually very easy in jQuery:
Change .appendTo() of course...
You can use clone() method to create a copy..
FIDDLE HERE