asp.net.ph

Skip Navigation Links

lastChild Property

DHTML Object Properties   DHTML Objects


DOM Level 1 Specification.

Returns a reference to the last child in the childNodes collection of an object.

Syntax


HTML N/A
Script [ oElement = ] object.lastChild

Possible Values


oElement The last child object.

If there is no such node, this property returns null. The property is read-only with no default value.

Example

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>
See Also

firstChild, nextSibling, previousSibling



>

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note