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

后端 未结 3 722
离开以前
离开以前 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 should work:

    $(this).nextAll().slice(0,4).attr(…)
    

    Update:

    This will work, too:

    $(this).nextAll("*:lt(4)").attr(…)
    

提交回复
热议问题