steve Kim steve Kim - 1 year ago 87
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!

Answer Source

You could use $.fn.nextAll():

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download