[英]Using jQuery can you select a set of siblings based on a number?
Example: 例:
<span>Bacon, Chris P.</span>
<span>Jones, Pete</span>
<span>Adams, Sam</span>
<span>Bacon, Chris P.</span>
<span>Jones, Pete</span>
<span>Adams, Sam</span>
<span>Bacon, Chris P.</span>
Using eq()
to choose where to start, how can one use jQuery to select an arbitrary number of siblings? 使用eq()
选择从哪里开始,如何使用jQuery选择任意数量的兄弟姐妹? Such as span:eq(0)
through span:eq(10)
? 例如span:eq(0)
到span:eq(10)
吗?
jQuery slice()
: jQuery slice()
:
$('<span>').slice(1, 10);
or you can use the :gt()
selector combined with the :lt()
selector: 或者 ,可以结合使用:gt()
选择器和:lt()
选择器:
$('<span>:gt(0):lt(10)'); // first 10 elements
Docs: 文件:
You could use nextUntil()
: 您可以使用nextUntil()
:
$('span:eq(2)').nextUntil( $('span:eq(6)') ).addBack()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.