Element.lastChild (Property)

The last child object contained within the DOM hierarchy that descends from this element.


DOM level - 1
JavaScript - 1.5
JScript - 5.0
Internet Explorer - 5.0
Netscape - 6.0
Property/method value type:Element object
JavaScript syntax:-myElement.children[anIndex]
Argument list:anIndexA value equal to the length of the array minus 1

The Element objects are instantiated as the HTML tags are parsed within the document source. They are added to several collections and can be navigated in a variety of ways.

Each Element object has an array of Element objects considered to be its direct descendants (that is children). This collection will not contain its children's children. The last element in this collection can be referred to by index and its siblings by means of an enumerator or for( ... in ... ) loop. However you can access it directly with this property.

Accessing the object at the end of the collection with this property is more convenient than measuring the length of the collection and accessing by array index.

If the element has no children, then this property will contain a null value.

See also:Element object, Element.firstChild, Element.nextSibling, Element.parentElement, Element.previousSibling, Node.lastChild

insert figure 0043