是否有任何jquery选择器支持循环轮询? [英] Is there any jquery selector to support round robin?

查看:94
本文介绍了是否有任何jquery选择器支持循环轮询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法可以在JQuery中选择next()子级,以便如果当前是最后一个,那么下一个应该是第一个同级?

Is there an easy way to select next() child in JQuery so that if current is last then next should be the first sibling?

推荐答案

您可以在父元素上使用eq.

You can use eq on parent element.

var len = $('#mySelector .child').length;
$('#mySelector .child').eq(i % len)....

HTML

<div id="mySelector">
    <span class="child"></span>
    <span class="child"></span>
    <span class="child"></span>
    <span class="child"></span>
    <span class="child"></span>
</div>

演示: http://jsfiddle.net/tusharj/88n9w98e/

这篇关于是否有任何jquery选择器支持循环轮询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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