Table of contents
- 1. Summary
- 2. Syntax
- 3. Example
- 4. See also
- 5. Browser compatibility
- 6. Specification
Summary
Returns the DOM node's parent Element
, or null if the node either has no parent, or its parent isn't a DOM Element
.
Syntax
parentElement = node.parentElement
parentElement is the parent element of the current node. This is always a DOM Element
object, or null.
Example
if (node.parentElement) {
node.parentElement.style.color="red";
}
See also
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | (Yes) | 9.0 (9.0) | (Yes) | (Yes) | (Yes) |
| Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | ? | 9.0 (9.0) | ? | ? | ? |


Mozilla Developer Network