the problem is that .next () and .nextAll () only search through siblings (elements that have the same parent element).
From the jQuery documentation:
Description: Get all of the following siblings of each element in the set of matched elements, optionally filtered by the selector.
In your case, you have:
<tr> <td> title here</td> <td><input name="user_name"/> </td> </tr> <tr> <td colspan="2"> <span class="error"></span> </td> </tr>
As I understand it, your jQuery code is running on input, right? In this case, before calling newxt () or nextAll (), you must first go to 2 levels until and then select the next one, because there is something you want to find, therefore:
here is a working example to check it out: http://jsfiddle.net/EM5Gw/
source share