How do I select the next “n” elements starting from the current element in jQuery?

后端 未结 3 762
离开以前
离开以前 2021-02-05 00:00

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

3条回答
  •  遇见更好的自我
    2021-02-05 00:18

    $(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.

提交回复
热议问题