.prevAll()
methodThe .prevAll()
method in jQuery is used to get all preceding siblings element of the matched elements.
.prevAll()
method Syntax.prevAll() .prevAll(selector)
.prevAll()
method ExampleFind all the items before Item3 and highlight them
HTML
<ul> <li class="one">item1</li> <li>item2</li> <li class="third">item3</li> <li>item4</li> <li>item5</li> </ul>
jQuery
$(".third").prevAll(); $(".third").prevAll('li'); $(".third").prevAll('.one');
Result
[<li>item2</li>,<li class="one">item1</li>] [<li>item2</li>,<li class="one">item1</li>] [<li>item1</li>]