Is there a way to clone HTML elements using JQuery?
However, I want to be able to assign the cloned elements new attributes \"id, name\". So if I had a textfield ele
documentation
I use jQuery over $ so it works with other libraries. Here is an example on an input text field.
jQuery('#example').clone().val('').attr('id', 'exmple2').attr('name', 'exmple2').insertAfter('#example');
If you want to clone the event handlers as well, you have to use clone(true).