Hello everybody I'm new in javascript. I want to create a button which duplicate elements in an array. I try this :
%a.btn.btn-success#addd{ :href => "#", :onclick => "duplicate(this.parentNode.parentNode)" }
:javascript
document.getElementById('addd').click = duplicate;
var i = 0;
var original = document.getElementById('inf_finding.id');
function duplicate(original) {
var clone = original.cloneNode(true);
clone.id = "inf_finding.id" + ++i;
original.parentNode.appendChild(clone);
}
But I refresh it, the element that I add is not in the page anymore.Can you help me to resolve this please ? Here are the screenshots :