DOM:element.parentNode
From MDC
Contents |
[edit] Summary
Returns the parent of the specified node in the DOM tree.
[edit] Syntax
parentNode = node.parentNode
parentNode is the parent of the current node. The parent of an element is an Element node, a Document node, or a DocumentFragment node.
[edit] Example
if (node.parentNode) {
// remove a node from the tree, unless
// it's not in the tree already
node.parentNode.removeChild(node);
}
[edit] Notes
parentNode returns null for the following node types: Attr, Document, DocumentFragment, Entity, and Notation.
It also returns null if the node has just been created and is not yet attached to the tree.
[edit] See also
element.firstChild, element.lastChild, element.childNodes, element.nextSibling, element.previousSibling.