YouTip LogoYouTip

Misc Contains

# jQuery.contains() Method [![Image 3: jQuery Misc Methods](#)jQuery Misc Methods](#) ## Example Check if one element contains another element: $(function () { function funcontain( html ){ document.body.innerHTML += "
" + html; } funcontain($.contains( document.documentElement, document.body )); // true funcontain($.contains( document.body, document.documentElement )); // false }) [Try it Β»](#) * * * ## Definition and Usage The $.contains() method is used to check if one element contains another element. In other words, it checks if another DOM element is a descendant of the specified DOM element. * * * ## Syntax _$_.contains( container, contained ) | Parameter | Description | | :--- | :--- | | _container_ | Element type. Specifies the ancestor container element that may contain other elements. | | _contained_ | Element type. Specifies the descendant element that may be contained by other elements. | * * jQuery Misc Methods](#)
← Misc GlobalevalSvn Check Out β†’