Return all previous sibling elements of each <li> element with class name "start":
Result:
The prevAll() method returns all previous sibling elements of the selected element.
Sibling elements are elements that share the same parent.
The DOM tree: This method traverse backwards along siblings of DOM elements.
Related methods:
Parameter | Description |
---|---|
filter | Optional. Specifies a selector expression to narrow down the search for
previous siblings Note: To return multiple siblings, separate each expression with a comma. |
Narrow down the search
How to filter the search for previous sibling elements.
Return multiple siblings
How to
use the filter parameter to return all siblings of a <h2> element that have
class names "1", "2" and "3".
Select
all previous sibling elements of a <p> element
How to select all previous sibling elements of a <p> element.
Select
all previous sibling <p> elements of <div>
How to select all previous sibling <p> elements of each <div> element.