(jQuery/Selectors)在指定类之后选择元素 [英] (jQuery/Selectors) select element after a specified class

查看:78
本文介绍了(jQuery/Selectors)在指定类之后选择元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用插件无限滚动

它需要用于下一页链接的选择器.我想如果导航如下,

it requires the selector for the next page link. i suppose that if the navigation is as follows,

<ul>
    <li><a href="#" class="active">page 1</a></li>
    <li><a href="#" class="next">page 2</a></li>
    <li><a href="#">page 3</a></li>
    <li><a href="#">page 4</a></li>
    <li><a href="#">page 5</a></li>
</ul>

i可以将"a.next"用作下一页的选择器.但是如果我的页面导航标记如下但没有.next

i can use "a.next" as the selector for the next page. but what happens if my page nav markup is as follows, without the .next class

<ul>
    <li><a href="#" class="active">page 1</a></li>
    <li><a href="#">page 2</a></li>
    <li><a href="#">page 3</a></li>
    <li><a href="#">page 4</a></li>
    <li><a href="#">page 5</a></li>
</ul>

假设.active表示当前页面,我如何选择页面2链接

how can i select the page 2 link assuming .active signifies the current page

推荐答案

要选择.active旁边的节点,可以使用next()函数:

To select the node next to .active, you can use the next() function:

$('.active').next();

但是为什么不添加始终存在的上一个/下一个列表项?

But why not add a prev/next list item that's always there?

这篇关于(jQuery/Selectors)在指定类之后选择元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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