From the course: The DOM in JavaScript, jQuery, AngularJS, and React
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Add, append, and delete DOM nodes
From the course: The DOM in JavaScript, jQuery, AngularJS, and React
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Select elements with getElementById7m 26s
-
(Locked)
Select elements with getElementsByClassName9m 41s
-
(Locked)
Select groups of elements with getElementsByName8m 8s
-
(Locked)
Select elements with getElementsByTagName6m 15s
-
(Locked)
Add, append, and delete DOM nodes13m 43s
-
(Locked)
Updating content in place4m 16s
-
-
-
-
-