JavaScript Reference/Javascript Properties/parentNode
"parentNode" Example
<source lang="javascript">
<html> <body> <form id="myF">
<input id="myB" type="button" value="Show parent node" onclick="function1();">
</form> <script language="JavaScript"> function function1() {
var m = document.all.myB.parentNode.id; alert("Parent node: <form>, id = "+"""+m+""");
} </script> </body> </html>
</source>
"parentNode" is applied to
<source lang="javascript">
+----------------+--------------------------------------------------------------+ | Applied_To |<a> <acronym> | | |<address> <applet> | | |<area> attribute | | | <base> | | |<basefont> | | |<bgsound> |
| |<body> || |
| |
<button> || | |
| |<dir>| | |<col> <colgroup> | | |<comment>
| | | || | |
- | | | <embed> | | |<fieldset> | | |<form> <frame> | | |<frameset> <head> | | |<hn>
|| |<html> | | |<iframe> <img> | | |<input type="button"> <input type="checkbox"> | | |<input type="file"> <input type="hidden"> | | |<input type="image"> <input type="password"> | | |<input type="radio"> <input type="reset"> | | |<input type="submit"> <input type="text"> | | | <isindex> | | | <label> |
| |<legend>- | | |<link> <listing> | | |<map> <marquee> | | |<menu> <meta> | | |<noframes> <noscript> | | |<object>
| | |<optgroup> <option> | | |
<param> | | |<plaintext>
| | || | | <script> | | |<select> | | || | | <style> | | | | | |<tbody> | | |
<textarea> | | |textNode <tfoot> |
| |<thead> | | |<title> | | | | | | | | |<xmp> | +----------------+--------------------------------------------------------------+ </source>
"parentNode" Syntax and Note
<source lang="javascript"> Note: Read-only property. Returns a reference to the node"s parent node.
Syntax:
document.getElementById("elementID").parentNode document.all.elementID.parentNode // IE only
</source>