I am facing an issue with dynamically appending the content of a pre-defined "old div" tag to a "new div." Unfortunately, the code I used does not seem to be working as expected. Moreover, I have another inquiry regarding how to remove the appended div tag dynamically.
<html>
<head>
<script type="text/javascript">
function add() {
var i = document.getElementById( 'old' );
var d = document.getElementById( 'new' );
d.appendChild( i );
}
</script>
</head>
<body>
<div id="old">
Content of old div
</div>
<div id="new">
</div>
<button onclick="add()">Add</button>
</body>
</html>