steve Kim steve Kim - 9 months ago 37
jQuery Question

jQuery eq() with different class name

I have following html:

<div class="block"></div>
<div class="block first"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block">this</div> // I need to target this to add another class
<div class="block"></div>

I want to select 3rd from the "block first" div:


Of course I am missing something. The "first" class is dynamically added to one of the "block" div and I need to target 3rd div from where the "first" class is added. Anyone with suggestion? Thanks!


You could use $.fn.nextAll():