If you need to delete an HTML element like one <div> or any other element existing in the HTML Document you have to :

1. Get the element by ID :

var element = document.getElementById("IdOfDiv");

2. Delete this element :

element.parentNode.removeChild(element);

If you need to insert an HTML element like one <div> or any other element before an existing element , try this simple tuto : how to insert an HTML element before another ?

Commentaires

  1. Pingback: Solution for: (JavaScript / TypeScript how to insert an HTML element before another ? » JavaTuto

Laisser un commentaire