hello
i need to duplicate div when i press button it all works
but how to make it counts +1 name not id
my code:
<?php
......
foreach($countries as $key => $value) {
?>
<?= htmlspecialchars($value) ?>
<?php
}
?>
document.getElementById('button').onclick = duplicate;
var i = 0;
var original = document.getElementById('duplicater');
function duplicate() {
var clone = original.cloneNode(true); // "deep" clone
clone.id = "duplicetor" + ++i; // there can only be one element with an ID
original.parentNode.appendChild(clone);
}
</script>
it duplicates this div
but i need it duplicates