getLastChild (DOMNode - JavaScript)

Gets the last child of a node.

Defined in

DOMNode

Syntax

getLastChild() : DOMNode

Return value Description
DOMNode The last child node or null.

Examples

This button gets the schema element of a DOM, then gets the elements at the next level in reverse order.
if (requestScope.n != null
&& requestScope.n < database.getDocumentCount()
&& requestScope.n >= 0) {
	var dc = database.getAllDocuments();
	var doc = dc.getDocumentArray()[requestScope.n];
	var schema = doc.getFirstChild(); // get node below root
	requestScope.y = "Child nodes of " + schema.getNodeName();
	var element = schema.getLastChild();
	while(element != null) {
		requestScope.y = requestScope.y +
			"\n\t" + element.getNodeName();
		element = element.getPreviousSibling();
	}
} else {
	requestScope.y = "No such document";
}
If the input XML to the DOM is as follows:
<schema0>
  <element0>foo</element0>
  <element1>bar</element1>
</schema0>
The display appears as follows:
Child nodes of schema0
	element1
	element0