Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the element before and after a specific element

I have a list with links I use with tabs. It looks like this:

<ul>
    <li><a href="#">First tab</a></li>
    <li><a href="#">Second tab</a></li>
    <li class="active"><a href="#">Active tab</a></li>
    <li><a href="#">Fourth tab</a></li>
    <li><a href="#">Fifth tab</a></li>
</ul>

How can I find the list element before and after the active tab? (In this case, the second and fourth tab).

Tried using find, with no success :(

like image 288
rebellion Avatar asked May 30 '09 12:05

rebellion


1 Answers

$("li.active").next();

and

$("li.active").prev();
like image 169
cletus Avatar answered Sep 18 '22 13:09

cletus