Alex Alex - 1 year ago 200
jQuery Question

jquery, find next element by class

How can i find the next element by class.

i tried with

but this returns classes only in
I need to take the next element anywhere throughout the code by class name.
Because my code looks like

<tr><td><div class="class">First</div></td></tr>
<tr><td><div class="class">Second</div></td></tr>

Is this possible?

Answer Source

In this case you need to go up to the <tr> then use .next(), like this:


Or if there may be rows in-between without the .class inside, you can use .nextAll(), like this:

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