Javascript JQuery选择不带类的tr元素
我有以下HTML代码:Javascript JQuery选择不带类的tr元素,javascript,jquery,Javascript,Jquery,我有以下HTML代码: <tr class="rowMain"></tr> --> if I click on this I should get the 2 <tr> below <tr></tr> <tr></tr> <tr class="rowMain"></tr> --> if I click on this I should get the
<tr class="rowMain"></tr> --> if I click on this I should get the 2 <tr> below
<tr></tr>
<tr></tr>
<tr class="rowMain"></tr> --> if I click on this I should get the 3 <tr> below
<tr></tr>
<tr></tr>
<tr></tr>
但这是在单击元素之后选择所有元素,最好的方法是什么?
$('.rowMain')。单击(函数(){
$(this.nextUntil('.rowMain',tr').hide();
});代码>
测试
1.
1.
测试2
2.
2.
2.
$('.rowMain')。单击(函数(){
$(this.nextUntil('.rowMain',tr').hide();
});代码>
测试
1.
1.
测试2
2.
2.
2.
只有code是答案通常不是好答案。请解释这个解决方案是如何解决问题的。只有代码才是答案通常不是好答案。请解释此解决方案如何解决问题。
$('.main').click(function(){
$(this).nextAll('tr').not('.rowMain');
});