Is there a simple way to copy content from one div to another while also changing the button's id by incrementing them?
For example:
<script type="text/javascript">
function add(){
document.getElementById('two').innerHTML = document.getElementById('one').innerHTML;
}
</script>
<div id="one">
<button id="button_1" >Button_1</button>
</div>
<div id="two"></div>
<button onclick="add();">Add</button>
The current implementation does not work as expected.
The desired result is as follows:
<div id="two">
<button id="button_2" >Button_2</button>
</div>
Is there any straightforward solution for this? Any suggestions are appreciated.