Reputation: 20468
Using jQuery selectors, how to find an element, such as div
, immediately after another specific element? (not sibling, next()
can not help in this situation)
Upvotes: 18
Views: 40654
Reputation: 20620
Maybe you are looking for the adjacent sibling selector:
http://www.w3.org/TR/CSS2/selector.html#adjacent-selectors
Upvotes: 2
Reputation: 50019
Use nextAll()
with a filter : http://api.jquery.com/nextAll/
Here's a demo : http://jsfiddle.net/JRPGh/1/
<div class='start'></div>
<div></div>
<div></div>
<div class='start'></div>
$('.start').nextAll('.start:first').css('background', 'red');
Upvotes: 23