在特定元素之前和之后查找元素 [英] Find the element before and after a specific element

查看:91
本文介绍了在特定元素之前和之后查找元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表,其中包含与制表符一起使用的链接.看起来像这样:

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).

尝试使用find,但没有成功:(

Tried using find, with no success :(

推荐答案

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

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

这篇关于在特定元素之前和之后查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆