asp.net.ph

Skip Navigation Links

parentNode Property

DHTML Object Properties   DHTML Objects


DOM Level 1.

Retrieves the parent node of the specified object.

Syntax

HTML N/A
Script [ oElement = ] object.parentNode

Possible Values

oElement Parent node.

The property is read-only with no default value.

Remarks

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.

Example

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;
See Also

childNodes


Need a break ?
Suggested Reading

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph.

If you have any question, comment or suggestion,
please send us a note