/

HTML / CSS / JavaScript Tutorial

JavaScript DOM HTML method: contains()

[this page | pdf | back links]

The contains() method (when applied to HTML elements in the JavaScript DOM) returns true if one node is a descendant of another node, otherwise returns false.

 

It has the following syntax with the following parameters (when applied to elements). It returns a Boolean which is true if node is a descendant of element.

 

element.contains(node)

 

Parameter

Required / Optional

Description

node

Required

The node object to compare with the current node or element

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile