问题描述
我在UL内部有大量LI,每个LI都有唯一的ID.
I have a load of LIs inside an UL, and each one has a unique ID.
给出两个ID,最好是选择两个对应的LI(和)之间的所有LI的最佳方法?
Given two IDs, what's the best way to select the two corresponding LIs, and all the LIs in between?
谢谢!
推荐答案
http://api.jquery.com /nextUntil/
如果选择器不匹配或没有提供选择器,则将选择以下所有同级;在这种情况下,它会选择没有提供过滤器选择器时与.nextAll()
方法相同的元素.
If the selector is not matched or is not supplied, all following siblings will be selected; in these cases it selects the same elements as the .nextAll()
method does when no filter selector is provided.
从jQuery 1.6起,可以将DOM节点或jQuery对象而不是选择器传递给.nextUntil()
方法.
As of jQuery 1.6, A DOM node or jQuery object, instead of a selector, may be passed to the .nextUntil()
method.
该方法可以选择接受第二个参数的选择器表达式.如果提供了此参数,则将通过测试元素是否匹配来对其进行过滤...
The method optionally accepts a selector expression for its second argument. If this argument is supplied, the elements will be filtered by testing whether they match it...
这篇关于jQuery选择器:选择两个元素,然后选择所有元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!