EN
Dieser Inhalt ist in Ihrer Sprache leider nicht verfügbar. Im Folgenden finden Sie die englische Version.

lastChild property

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

Syntax

JavaScript

p = object.lastChild

Property values

Type: Object

the last child.

Standards information

Examples

The following code example implements the lastChild property to obtain a reference to the last child element of an object.



<!DOCTYPE html>

<html>
<head>
  <title>lastChild</title>
</head>
<body>
  <ul id="oList">
    <li>List Item 1</li>
    <li>List Item 2</li>
    <li>List Item 3</li>
  </ul>
  <script>
    var olastChild = document.getElementById('oList').lastChild;
    console.log(olastChild.previousSibling.textContent); // Outputs "List Item 3".
  </script>
</body>
</html>

See also

a
abbr
acronym
address
applet
area
attribute
b
base
baseFont
bdo
big
blockQuote
body
button
caption
center
cite
code
col
colGroup
comment
dd
del
dfn
dir
div
dl
documentType
dt
em
embed
fieldSet
font
form
frame
frameSet
head
hn
hr
html
i
iframe
img
input type=button
input type=checkbox
input type=email
input type=file
input type=image
input type=number
input type=password
input type=radio
input type=range
input type=reset
input type=search
input type=submit
input type=tel
input type=text
input type=url
ins
kbd
label
legend
li
link
listing
map
marquee
menu
nextID
ol
option
p
plainText
pre
ProcessingInstruction
q
s
samp
script
select
small
span
strike
strong
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
title
tr
tt
u
ul
var
xmp
Reference
firstChild
Conceptual
About the W3C Document Object Model

 

 

Anzeigen:
© 2014 Microsoft