简体   繁体   中英

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

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

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

See adjacent sibling selectors .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM