JS DOM: Remove an Element or Childen

By Xah Lee. Date: .

Remove Child

parent.removeChild(oldNode)

Replace Child

parent.replaceChild(newNode, oldNode)

Replaces the child node oldNode of parent with newNode.

🛑 WARNING: If newNode is in the same doc, move it to the new place.

Remove all children

Replace all children by text

DOM Element Methods

Get node
Loop thru nodes
Attributes
Create insert node
Delete
Change content
Event