lastChild
Summary
Gets a reference to the last child in the childNodes collection of an object.
Syntax
var result = element.lastChild;
element.lastChild = value;
Examples
The following code example implements the lastChild property to obtain a reference to the last child element of an object.
<body>
<ul id = "oList">
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ul>
<script type="text/javascript">
var olastChild = oList.lastChild;
</script>
<body>
Usage
Used to remove and append nodes to user lists and tables.
Syntax
var last_child = element.lastChild
Standards information
- Document Object Model (DOM) Level 1 Specification, Section 1.2
Related specifications
- DOM Level 2 Core
- Recommendation
Attributions
Mozilla Developer Network : [Node.lastChild Article]
Microsoft Developer Network: [lastChild Property Article]