January 5, 2000 - Establishing Parent-Child Connections
January 5, 2000|
Establishing Parent-Child Connections
Tips: January 2000
Yehuda Shiran, Ph.D.
appendChild()method establishes a father-child relationship between two nodes. If the father node has children already, the new child will be appended as the last one, and hence can be accessed via the
lastChild()method. When calling the
appendChild(), the child node is specified as the method's parameter:
applyElement() method connects a child to its target father, which has been stripped down from its existing children and father. When calling the
applyElement() method, the father node is specified as the method's parameter:
There are four differences between this method and the previous
appendChild() method operates on the father object and expects the child object as its parameter. The
applyElement() method, on the other hand, operates on the child object and expects the father object as a parameter.
applyElement() method strips the target father from its both existing children and existing father before connecting the new child. The appendChild method, on the other hand, does not touch its target father's family.
applyElement() method does not operate on text nodes. The appendChild method, on the other hand, does operate on both HTML tag nodes and text nodes.
Learn more about the DOM's properties and how to use them, in Column 44, The Document Object Model (DOM), Part 5