How do I select the next \"n\" elements starting from the current element? What I mean is...
$(this).attr(...);
I want to do this \"n\" times
This should work:
$(this).nextAll().slice(0,4).attr(…)
Update:
This will work, too:
$(this).nextAll("*:lt(4)").attr(…)
$(this).slice(start_index, end_index)
will select a portion of your selection. You could keep track of your current index in the loop and then apply the .slice(cur_index, cur_index+n)
function on the original set when you hit your condition.
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.