Your Search Results

    Node.contains Redirect 1


    Indicates whether a node is a descendant of a given node.


    node.contains( otherNode ) 
    • node is the node that's being compared.
    • otherNode is the node that's being compared against.

    The return value is true if otherNode is a descendant of node, or node itself. Otherwise the return value is false.


    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);
    • node is the node we want to check for in the <body>.

    Browser compatibility

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


    See also

    Document Tags and Contributors

    Contributors to this page: Sheppy
    Last updated by: Sheppy,