How do I select the next "n" elements starting from the current element in jQuery?
Solution 1:
This should work:
$(this).nextAll().slice(0,4).attr(…)
Update:
This will work, too:
$(this).nextAll("*:lt(4)").attr(…)
Solution 2:
the nextAll
method selects the following siblings of an element, optionally filtered by a selector. You could then follow that with a slice
to restrict to a smaller n.