DHTML Object Properties DHTML Objects
DOM Level 1.
Retrieves the parent node of the specified object.
HTML |
N/A |
Script |
[ oElement = ] object.parentNode |
The property is read-only with no default value.
All nodes, except Document, DocumentFragment, and Attr may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is NULL.
The topmost object returns NULL as its parent.
The following samples demonstrate implementation of the parentNode attribute.
The first sample shows how the parentNode value of a SPAN object is assigned to a variable.
<script language="JavaScript">
var oParent = oSpan.parentNode;
</script>
...
<body>
<span id=ospan>A Span</span>
<body>
The second sample shows how the parentNode value of a node created with the createElement method is assigned to a variable.
var oNode = document.createElement ( "B" );
document.body.insertBefore ( oNode );
var sType = oNode.parentNode;
childNodes