mozilla
Your Search Results

    Node.contains()

    The Node.contains() method returns a Boolean value indicating whether a node is a descendant of a given node. or not.

    Syntax

    node.contains( otherNode ) 
    

    Example

    This function checks to see if an element is in the page's body. As contains is inclusive and determining if the body contains itself isn't the intention of isInPage this case explicitly returns false.

    function isInPage(node) {
      return (node === document.body) ? false : document.body.contains(node);
    }

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support (Yes) 9.0 (9.0) 5.0 (only for Elements) (Yes) 3.0 [1][2]
    Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support ? 9.0 (9.0) ? ? ?

    Specification

    See also

    Document Tags and Contributors

    Last updated by: fscholz,