是否有一种简单的方法可以在 JQuery 中选择 next()
子级,以便如果 current 是最后一个,那么 next 应该是第一个同级?
最佳答案
您可以在父元素上使用eq
。
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>
关于javascript - 有没有支持循环的jquery选择器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30621218/