Andrei
Andrei

Reputation: 4617

jQuery selector question

I have a unordered list like the one below:

<ul id="tabs">
      <li><a href="#tab1">latest news</a></li>
      <li class="active"><a href="#tab2">latest posts</a></li>
      <li><a href="#tab3">latest posts</a></li>
      <li><a href="#tab4">latest posts</a></li>
</ul>

I can't find a jQuery selector that gets the next list item from the one whith the .active class, so if .active is the second one the jQuery selector will give me the third list item.

Thank's

Upvotes: 0

Views: 115

Answers (2)

Quentin
Quentin

Reputation: 943108

In one step: jQuery('li.active + li');

See adjacent sibling selectors.

Upvotes: 3

Soufiane Hassou
Soufiane Hassou

Reputation: 17750

$('ul#tabs li.active').next();

Upvotes: 3

Related Questions