Jquery Select element 2 positions further - another way to .next().next()

后端 未结 2 1760
无人及你
无人及你 2021-01-04 05:40

I am searching for a way how I could select a div element which is not the direct next one to the one which is \"selected\" by a click function.

相关标签:
2条回答
  • 2021-01-04 06:23

    You can use .nextAll() with .eq() for your dynamic approach, like this:

    $(this).nextAll().eq(1) //0 based index, this would be .next().next()
    

    This would allow you to get n siblings forward, which seems to be what you're after.

    0 讨论(0)
  • 2021-01-04 06:25

    It seems that $(this).parent().find('div').eq(2).attr('id') should work.

    UPDATE( Added find('div') )

    0 讨论(0)
提交回复
热议问题