Element.contains() (Method)

A test to see if the element contains another element.


JScript - 3.0
Internet Explorer - 4.0
Opera - 5.0
Property/method value type:Boolean primitive
JavaScript syntax:IEmyElement.contains(anElement)
Argument list:anElementAn Element object to check for

The receiving element hierarchy is checked to see if the element that is passed as an argument exists by reference within it.

The result of this method will be true if the element referred to by its argument is contained in the receivers node descendants. If by traversing the child nodes of the receiver the indicated element cannot be found, a false value is returned.

The functionality of this method is similar to that provided by the DOM level 1 compliant Node.hasChildNodes() method which should provide a more portable solution.

See also:Element object, Node.hasChildNodes()

insert figure 0046