Your Search Results


    This article is in need of a technical review.

    The Node.parentElement read-only property returns the DOM node's parent Element, or null if the node either has no parent, or its parent isn't a DOM Element.


    parentElement = node.parentElement

    parentElement is the parent element of the current node. This is always a DOM Element object, or null.


    if (node.parentElement) { = "red";

    Browser compatibility

    On some browsers, the parentElement property is only defined on nodes that are themselves an Element. In particular, it is not defined on text nodes.

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support (Yes) 9.0 (9.0) (Yes) (only on Element) (Yes) (only on Element) (Yes)
    Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support ? 9.0 (9.0) ? ? ?


    See also

    Document Tags and Contributors

    Last updated by: fscholz,