jQuery.contains() in JQuery


Description: Check to see if a DOM node is within another DOM node.

  • version added: 1.4jQuery.contains( container, contained )

    containerThe DOM element that may contain the other element.

    containedThe DOM node that may be contained by the other element.


Check if an element is inside another.

jQuery.contains(document.documentElement, document.body); // true
jQuery.contains(document.body, document.documentElement); // false

Leave a Reply

Your email address will not be published. Required fields are marked *