I am trying to clone a div and all of its children, and append the clone onto the end of the original when the user clicks a button and change the id
of child element, but for some reason I can't even get my div
to clone and append.
<div id="section">
//bunch of textboxes, labels, etc.
</div>
Here is my button
<input type="button" value="Add New Section" id="addSection"/>
Here is my Jquery
$(function() {
var $section = $("#section").clone();
$( "#addSection" ).click(function() {
$section.append(); // I've tried this and appendTo, Insert, InstertAfter, After, etc.. still cannot get this to work..
});
});
Ignore the fact that this doesn't change any child element id's, why is this not cloning and appending?
EDIT
I guess to clarify, I am trying to clone the original state of my div and append that every time my button is clicked.