Easy Tutorial
❮ Jquery Traversing Siblings Eff Clearqueue ❯

jQuery prevAll() Method

jQuery Traversing Methods

Example

Return all sibling elements before each <li> element with the class name "start":

$(document).ready(function(){
    $("li.start").prevAll().css({"color":"red","border":"2px solid red"});
});

Result:

ul (parent)  
    li (sibling)
    li (sibling)
    li (sibling)
    li (sibling with class name "start")
    li (sibling)
    li (sibling)

Definition and Usage

The prevAll() method returns all sibling elements before the selected element.

Sibling elements are elements that share the same parent.

DOM Tree: This method traverses backwards along sibling elements of the DOM elements.

Related methods:


Syntax

Parameter Description
filter Optional. Specifies a selector expression to narrow down the search for sibling elements before the element. <br> <br> Note: To return multiple sibling elements, use a comma to separate each expression.

More Examples

Narrow Down the Search

Return Multiple Sibling Elements

Select All Sibling Elements Before a <p> Element

Select All Sibling <p> Elements Before a <div> Element


jQuery Traversing Methods

❮ Jquery Traversing Siblings Eff Clearqueue ❯