aspxtreme

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



Books and more ...

Contents
HTML Elements / DOM Objects
HTML Element Attributes
CSS Attributes
DOM Object Properties
DOM-compliant Events Reference
DOM Methods Reference
DOM Collections Reference
 


Suggested Reading



Previous page Back to top Next page

Check out related books at Amazon

© 2000-2008 Rey Nuñez All rights reserved.

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

You can help support aspxtreme