Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JQuery选择不带类的tr元素_Javascript_Jquery - Fatal编程技术网

Javascript JQuery选择不带类的tr元素

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

我有以下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 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');
});