Remove Element

Remove an element from the DOM.

Preview

Code

<div id="removeBox">Remove me</div>

<button onclick="removeElement()">Remove</button>

<script>
function removeElement(){
  let el = document.getElementById("removeBox");
  el.remove();
}
</script>

More JS HTML DOM Examples (7)