Web APIs
Element.previousElementSibling
Find the preceding element sibling, skipping non-element siblings. Example console output: true.
Formal Syntax & Structure
javascript syntaxjavascript
element.previousElementSiblingReturn Value
Element or null
Previous element sibling or null.
Working Example
Example Snippetjavascript
const root=document.createElement("div"); const a=document.createElement("i"),b=document.createElement("b"); root.append(a,"gap",b); console.log(b.previousElementSibling===a);