We use the appendChild
method
to add nested HTML elements
inside another element.
In the example given below,
we append a red coloured box
to the end of a list of boxes:
The appended child gets added to
the last, after all other children
of the parent element.
It isn't necessary to append
only newly created elements.
We can even use this method
to move elements around the
document.