previousSibling property
Node?
get
previousSibling
inherited
The read-only previousSibling
property of the Node
interface
returns the node immediately preceding the specified one in its parent's
Node.childNodes
list,
or null
if the specified node is the first in that list.
Note: Browsers insert text nodes into a document to represent whitespace in the source markup. Therefore a node obtained, for example, using
Node.firstChild
orNode.previousSibling
may refer to a whitespace text node rather than the actual element the author intended to get.See Whitespace in the DOM for more information.
You can use
previousElementSibling
to get the previous element node (skipping text nodes and any other non-element nodes).To navigate the opposite way through the child nodes list use Node.nextSibling.
Implementation
external Node? get previousSibling;