previousSibling (W3C DOM Core property)
var sibling = node.previousSibling;
In the example above, if node has a sibling immediately
before it (a node of any type, which shares its parent with
node), the sibling variable will be
a reference to that node; otherwise it will be
So in the following HTML example, the first
element is the
previousSibling of the second, but
previousSibling of its own:
<h2>Shopping list</h2> <ul> <li>Beer</li> <li>More beer</li> </ul>
Actually this example is idealized, and in some browsers the first
li element may not in fact be the
previousSibling of the second; that's because
some browsers count intermediate whitespace as text nodes, and would
therefore consider the
previousSibling to be
the whitespace between the
For more about this behavior please see DOM Core.
The node immediately before
this node (ie. both nodes have the same parent and are next to each other
childNodes collection), or
null if there is no such node.
This property is readonly.
No known issues.