I have a form on a page. The form contains text inputs, checkboxes, selects (interactive elements). I want the user to be able to click a button, and reproduce a portion of the form elsewhere on the page, in the current state, preserving the text entered, the checkboxes checked, and the selects selected.
Currently I have this, which appends the HTML, however it grabs the HTML in the state it was when the page was loaded.
$('#create_unique_field').click( function() {
$('#unique_field_cnt').append($('#template_cnt').html());
});
I have tried using delegation using on(), like so, with the same results.
$( 'body' ).on( 'click', '#create_unique_field', function() {
$('#unique_field_cnt').append($('#template_cnt').html());
});
What I want is the current state of the HTML, not the HTML at the point when the page was loaded. How can I accomplish this?