{"name":"jQuery.contains","type":"method","title":"jQuery.contains()","deprecated":null,"removed":null,"desc":"Check to see if a DOM element is a descendant of another DOM element.","categories":["utilities","version/1.4"],"entries":[{"return":"Boolean","signatures":{"added":"1.4","argument":[{"desc":"The DOM element that may contain the other element.","name":"container","type":"Element"},{"desc":"The DOM element that may be contained by (a descendant of) the other element.","name":"contained","type":"Element"}]},"examples":{"desc":"Check if an element is a descendant of another.","code":"\n$.contains( document.documentElement, document.body ); // true\n$.contains( document.body, document.documentElement ); // false\n"},"longdesc":"\n

The $.contains() method returns true if the DOM element provided by the second argument is a descendant of the DOM element provided by the first argument, whether it is a direct child or nested more deeply. Otherwise, it returns false. Only element nodes are supported; if the second argument is a text or comment node, $.contains() will return false.

\n
\n

Note: The first argument must be a DOM element, not a jQuery object or plain JavaScript object.

\n
\n "}]}