Javascript 我怎样才能得到元素后面有类的所有行,当它到达一个没有类的行时应该停止
我试图实现的是获取当前行之后的所有Javascript 我怎样才能得到元素后面有类的所有行,当它到达一个没有类的行时应该停止,javascript,jquery,Javascript,Jquery,我试图实现的是获取当前行之后的所有行。 它应该获取它之后的所有行,直到它不再有任何特定的类为止。 例如: <tr class="clicked_el"></tr> <tr class="getme"></tr> <tr class="getme"></tr> <tr class="getme"></tr> <tr class="getme"></tr> <tr>&l
行。
它应该获取它之后的所有行,直到它不再有任何特定的类为止。
例如:
<tr class="clicked_el"></tr>
<tr class="getme"></tr>
<tr class="getme"></tr>
<tr class="getme"></tr>
<tr class="getme"></tr>
<tr></tr> //It should stop here
<tr class="getme></tr>
//应该到此为止
您可以将jQuery方法与伪类选择器一起使用
$('tr.clicked_el').nextUntil(':not(.getme)')
$('tr.clicked_el').nextUntil(':not(.getme)).html('selected')
您可以使用$(“.clicked_el”).nextUntil(“:not(.getme)”)
这将返回:
<tr class="clicked_el"></tr>
<tr class="getme"></tr> <- This will be returned;
<tr class="getme"></tr> <- This will be returned;
<tr class="getme"></tr> <- This will be returned;
<tr class="getme"></tr> <- This will be returned;
<tr></tr>
<tr class="getme></tr>
后续问题。。在最后一个tr
后续问题之后,我是否可以通过getme
获得最后一个tr
。。在最后一个tr
@reyyoung$('tr.clicked_el tr:last')之后,有没有办法用getme
获取最后一个tr