Get the node name of the parent element of a <li> element:
The result of x will be:
The parentElement property returns the parent element of the specified element.
The difference between parentElement and parentNode, is that parentElement returns null if the parent node is not an element node:
In most cases, it does not matter which property you use, however, parentNode is probably the most popular.
This property is read-only.
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
parentElement | 1.0 | Yes | 9.0 | Yes | Yes |
Return Value: | An Element object, representing the parent element node of a node, or null if the node has no parent |
---|---|
DOM Version | DOM Level 4 Element Object |