Variations on Adding elements

Learn how to use several methods to add the elements in an existing HTML page.

Adding a textual node

Instead of using the textContent property to define the new element’s textual content, you can create a textual node with the createTextNode() method. This node can then be added to the new element with appendChild(). The following code demonstrates this possibility by inserting the Ruby language at the end of the list.

Get hands-on with 1400+ tech skills courses.