From the course: The DOM in JavaScript, jQuery, AngularJS, and React

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Add, append, and delete DOM nodes

Add, append, and delete DOM nodes

From the course: The DOM in JavaScript, jQuery, AngularJS, and React

Start my 1-month free trial

Add, append, and delete DOM nodes

- [Instructor] In this video, we'll be using JavaScript to interact with the DOM by adding and deleting nodes from the DOM tree. Now all the methods that we learned things like for example you get element by ID, get elements by tag name and so forth, those are the ones that are very very useful for doing that. So the first thing we'll be doing is by adding a new node into the tree we're inserting right before another existing node. So first we're going to add three buttons on the top of this contact us heading. Those buttons will say add before, add after, and delete or remove the node. And so the first one adding a node will be adding one right between the words contact us here and the paragraph and then when we add after we'll add another button down there at the end right below the form here as well. So why don't we go into Brackets and start coding. So the first thing I want to add are the three buttons and we want to do that above the form because if you put inside the form it's…

Contents