...

/

Adding New Child Elements to the Document

Adding New Child Elements to the Document

In this lesson, we will add new child elements to our document tree. Let's begin!

After you have grabbed a document element, you can add child elements to it with the appendChild() and insertBefore() methods.

The first method appends a new child to the end of the list of exiting children

The second method allows specifying the position of insertion. The Listing below demonstrates using them.

Listing: Using appendChild(), and insertBefore() methods

Access this course and 1400+ top-rated courses and projects.