I need to repeated large section (Account details section- Please see demo) when user click on add. What is the easy and best way to add/remove dynamically the whole section? Note. When user submits, I should be able to validate and capture the data so each field must be unique.
HTML:
<button type="button" id="AddCC" class="btn btn-warning form-control">Add Another Card</button>
Javascript:
$(document).ready(function() {
$('#AddCC').bind('click', function() {
alert("Add clicked");
$("#CCPanel").clone().appendTo("#container");
});
Actually Clone is working perfect. I just placed id in wrong div tag before. Now my question is how to make fileds unique for validating and submiting ? Please see updated demo.
clone()also in your case, and simply add class to cloned form to refernce the new input fields :)