previousElementSibling
The previousElementSibling property in JavaScript returns the element immediately preceding the specified element in its parent's childNodes list. It returns null if the specified element is the first child of its parent or if there is no preceding element sibling. This property is part of the Element Traversal API.
Unlike previousSibling, which can return any node type (including text nodes or comment nodes), previousElementSibling specifically
The browser support for previousElementSibling is widespread, with modern browsers fully supporting it. It is a
To use previousElementSibling, you first need to obtain a reference to the target element, typically using