Find out if a <span> element is a descendant of a <div> element:
The result of div will be:
The contains() method returns a Boolean value indicating whether a node is a descendant of a specified node.
A descendant can be a child, grandchild, great-grandchild, and so on.
The numbers in the table specify the first browser version that fully supports the method.
Method | |||||
---|---|---|---|---|---|
contains() | Yes | 5.0 | 9.0 | 3.0 | Yes |
Parameter | Description |
---|---|
node | Required. Specifies the node that may be contained by (a descendant of) a specified node |
Return Value: |
A Boolean, indicating whether a node is a descendant of a specified node:
|
---|