EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

previousSibling property

Gets a reference to the previous child of the parent for the object.

Syntax

JavaScript

p = object.previousSibling

 

Property values

Type: Object

a reference to the previous sibling of an object.

Standards information

Remarks

In Microsoft Internet Explorer 6, this property applies to the attribute object.

Examples

This example uses the previousSibling property to obtain the previous sibling of a list item.


<!DOCTYPE html>
<html>
<head>
  <title>previousSibling</title>
</head>
<body>
  <ul id="oList">
    <li>List Item 1</li>
    <li>List Item 2</li>
    <li>List Item 3</li>
  </ul>
  <script>
    // Returns the list item labeled 'List Item 1'
    var oSibling = document.getElementById('oList').childNodes[3].previousSibling.previousSibling;
    console.log(oSibling.textContent);
  </script>
</body>
</html>

See also

a
abbr
acronym
address
applet
area
attribute
b
base
baseFont
bdo
bgSound
big
blockQuote
body
br
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=hidden
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
object
ol
option
p
plainText
pre
ProcessingInstruction
q
s
samp
script
select
small
span
strike
strong
sub
sup
table
tBody
td
textArea
TextNode
tFoot
th
tHead
title
tr
tt
u
ul
var
xmp
Reference
lastChild
Conceptual
About the W3C Document Object Model

 

 

Afficher:
© 2014 Microsoft