$(document).ready(function() { var removeButton = "<button id='remove'>Remove</button>"; $('#add').click(function() { $('div.container:last').after($('div.container:first').clone()); $('div.container:last').append(removeButton); /*following is the line not to jump to top of the page */ return false; }); $('#remove').live('click', function() { $(this).closest('div.container').remove(); }); });
<div class='container'> Name<input type='text' name='name[]'> Year<input type='text' name='year[]'> Description<input type='text' name='description[]'> </div> <button id='add'>Add</button>