Jquery 选择具有类foo的下n个元素
如何使用jQuery选择下n个具有类“foo”的隐藏元素?使用and:Jquery 选择具有类foo的下n个元素,jquery,Jquery,如何使用jQuery选择下n个具有类“foo”的隐藏元素?使用and: :lt()选择器选择下一个n元素,:hidden选择器隐藏输入。Boldewyn的答案有效,但不需要过滤器。这还将仅选择隐藏的图元: $(this).nextAll('.foo:hidden:lt('+n+')') 你可以添加:hidden来选择隐藏的输入(根据OP的要求)+1我在第一次扫描时也错过了问题的“隐藏”部分。 $(this).nextAll('.foo:hidden:lt('+n+')') $(this).n
:lt()
选择器选择下一个n
元素,:hidden
选择器隐藏输入。Boldewyn的答案有效,但不需要过滤器。这还将仅选择隐藏的图元:
$(this).nextAll('.foo:hidden:lt('+n+')')
你可以添加:hidden
来选择隐藏的输入(根据OP的要求)+1我在第一次扫描时也错过了问题的“隐藏”部分。
$(this).nextAll('.foo:hidden:lt('+n+')')
$(this).nextAll('.foo:hidden').filter(':lt('+n+')')