Jack Johnson
Jack Johnson

Reputation: 611

Locate a href after element

I'm hoping that you have the answer to my question, i'm using jQuery to addClass to the link right after the "current" element. (link to page 2 in this example). I'm not able to do so with ".pagination > .current > a" etc. Any ideas ?

<div class="pagination">
    <span class="current">1</span> | 
    <span><a href="#">2</a></span> | 
    <span><a href="#">3</a></span> | 
    <span><a href="#">4</a></span> | 
    <span><a href="#">5</a></span>
</div>

Upvotes: 0

Views: 30

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337560

You can select the .current element, then use next and find to get the a element, something like this:

$('.current').next().find('a').addClass('foo');

Upvotes: 3

Related Questions