DHTML Object Properties DHTML Objects
DOM Level 1 Specification.
Returns a reference to the last child in the childNodes collection of an object.
HTML |
N/A |
Script |
[ oElement = ] object.lastChild |
oElement |
The last child object. |
If there is no such node, this property returns null. The property is read-only with no default value.
The following sample demonstrates the implementation of the lastChild property to obtain the last child element of an object. Click on an element to see.
This is a list in a DIV
- List Item 1
- List Item 2
- List Item 3
And this is a paragraph in the DIV.
This is a heading in a second DIV
And this is a blockquote in the second DIV.
<div id=div1 onclick="getLast ( this )">
<ul>This is a list in a DIV
<li>
<li>List Item 1
<li>
<li>List Item 2
<li>
<li>List Item 3
</ul>
<p>And this is a paragraph in the DIV.</div>
<div id=div2 onclick="getLast ( this )">
<h3>This is a heading in a second DIV</h3>
<blockquote>And this is a blockquote in
the second DIV.</blockquote></div>
<script language="JavaScript">
function getLast ( objID ) {
var oLast = objID.lastChild;
alert ( 'The lastChild of this DIV is a ' +
oLast.tagName );}
</script>
firstChild, nextSibling, previousSibling