Bug Tracker

Opened 14 years ago

Closed 14 years ago

#4875 closed enhancement (invalid)

prevAll() not including current element

Reported by: fmachs Owned by:
Priority: trivial Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: Cc: fmachs
Blocked by: Blocking:



I came into a problem where .prevAll() required use of current element. In the current jQuery release, .prevAll() seems not including the current element.


<div> <a href="#"></a> <a href="#"></a> <a href="#"></a> </div>

$('div a:nth-child(2)').prevAll().css('background-color', #000');

The above code would add the background-color to the <a>s before <a> 2 and would not include the <a> 2.

It would be nice to have an option of setting when to include the current element or not in the .prevAll() ( didn't tested .nextAll() ).

Change History (1)

comment:1 Changed 14 years ago by flesler

Cc: fmachs added
Resolution: invalid
Status: newclosed

Just do this:

$('div a:nth-child(2)').prevAll().andSelf().css('background-color', #000');

Note: See TracTickets for help on using tickets.