I have set up the following JSFiddle
My application has several .formContent rows, I am only displaying one row in the fiddle.
What I am trying to do is duplicate the div with the class .labelAndInput if the checkbox is checked, and place a new one underneath.
The new divs label and input should have the same id/name as the one copied, but with "testing" on the end of them.
At the moment I am trying something like this which does not seem to do anything :
$(function() {
$('input:checkbox[name=label1Newline]').change(function() {
if ($(this).checked) {
$(this).parent().siblings(".labelAndInput").clone().insertAfter("div.labelAndInput:last");
}
});
});
How can I clone the div, change the ids/names to include testing, and then append it?
Thanks
$(this).checkedwith$(this).prop("checked"). It works: jsfiddle.net/vt2czgse/43this.checked:)