Baseline Widely available
The contains()
method of the Node
interface returns a boolean value indicating whether a node is a descendant of a given node, that is the node itself, one of its direct children (childNodes
), one of the children's direct children, and so on.
Note: A node is contained inside itself.
Syntax ParametersotherNode
The Node
to test with.
Note: otherNode
is not optional, but can be set to null
.
A boolean value that is true
if otherNode
is contained in the node, false
if not.
If the otherNode
parameter is null
, contains()
always returns 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);
}
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4