appendChild (W3C DOM Core method)
The example above will append newnode at the end of node's list of children.
node is actually an HTML
newnode is a
Text node with the
wins, then the operation above would result in
<p>Love always wins</p>
- new node (
The new node to be added to this node. If the new node has any children these are also added recursively, preserving the new node's sub-tree.
Add a new node (and its subtree, if applicable) to the end of the list of children of this node.
If the new child is already present in the DOM tree it is first
removed (effectively moving it). If the new child is a
DocumentFragment node then the entire contents of the
document fragment are appended, but the fragment node itself is not
(therefore using a document fragment is a good way of building and
attaching several nodes at once).
The node that was added
says that this method should throw a
when attempting to append a node which was created in a different document
Therefore if a browser supports this and does not throw an exception, this
is considered a bug, and is what happens in
Opera, Firefox 1.5 and
2 and Safari 3.
In Safari 1.3 and 2 attempting to append a node which was created in a different document causes the browser to crash.
Overall then — don't use
appendChild to move
nodes between documents, use
importNode instead, because that's what it's