Selecting the next n items with class foo

How to select the following n hidden elements that have class "foo" using jQuery?

+3
source share
3 answers

Boldewyn's answer works, but filternot required. It also selects only hidden elements:

$(this).nextAll('.foo:hidden:lt('+n+')')
+3
source

Using nextAll () and filter () :

$(this).nextAll().filter('.foo:hidden:lt('+n+')');

The selector :lt()selects the following nitems, hidden inputs :hidden.

+2
source
$(this).nextAll('.foo:hidden').filter(':lt('+n+')')
0
source

Source: https://habr.com/ru/post/1738465/


All Articles