<body>
<div id="box">
<script>
class Sample {
//
}
</script>
</div>
</body>
In the code above, after deleting the node with the remove() method, Again, the contents of the node were added to the body with the appendChild method. Class repetition declaration error(Uncaught SyntaxError: Identifier 'Sample' has already been declared) occurs. I confirmed that the node was deleted.
How do I delete the node so it doesn't throw an error?