Javascript jQuery-在筛选匹配后获取表行

Javascript jQuery-在筛选匹配后获取表行,javascript,jquery,filter,html-table,rows,Javascript,Jquery,Filter,Html Table,Rows,我有一个HTML表,我正在使用jQuery进行过滤,以便根据特定类的单元格内容删除行。以下代码适用于此: $(function(){ $('#data td.a1').filter(function() { return $(this).text().match(/some value/) != null; }).parent().remove(); }); 但是,我还需要删除每个匹配行后面的两行。我该怎么做?我基本上是一个jQuery新手 非常感谢。听起来像是

我有一个HTML表,我正在使用jQuery进行过滤,以便根据特定类的单元格内容删除行。以下代码适用于此:

$(function(){
    $('#data td.a1').filter(function() {
        return $(this).text().match(/some value/) != null;
    }).parent().remove();
});
但是,我还需要删除每个匹配行后面的两行。我该怎么做?我基本上是一个jQuery新手

非常感谢。

听起来像是你想要的

编辑:我误解了。你想要下一个。
编辑2:如果表的结构使您要匹配的值每隔3行出现一次,因为3行的组在逻辑上是相关的,那么您可以使用nextUntil获取下一个2:

$(function(){
    var items = $('#data td.a1').filter(function() {
        return $(this).text().match(/some value/) != null;
    }).parent();
    items.nextUntil('.3rdRowInPattern').remove();
});

此外,如果3行的组在逻辑上是相关的,您可以将每组3行放入它们自己的
(这是允许的),然后只删除tbody。

我不得不猜测您的HTML结构。我在这里创作了一把小提琴


它与fadeOut()一起使用,但与remove()不一起使用。这是因为remove会立即从文档中删除元素,因此没有下一行。第二行和第三行包含基本上是垃圾输出的内容-这是由遗留系统生成的,否则我会在其源代码处更改结构。你的第一个建议很完美,谢谢!
$(function(){
    var items = $('#data td.a1').filter(function() {
        return $(this).text().match(/some value/) != null;
    }).parent();
    items.nextUntil('.3rdRowInPattern').remove();
});
<table id="data">
    <tr>
        <td class="a1">hello</td>
        <td class="a1">REMOVE</td>
        <td class="a1">hello</td>
    </tr>
    <tr>
        <td class="a1">hello</td>
        <td class="a1">hello</td>
        <td class="a1">hello</td>
    </tr>
    <tr>
        <td class="a1">hello</td>
        <td class="a1">hello</td>
        <td class="a1">hello</td>
    </tr>
</table>
var removeExpression="REMOVE";

$(function () {    
    $('table#data tr').filter(function(){
        var contains=false;

        $(this).find('td').each(function(index,value){            
            contains=contains||$(value).text().match(removeExpression);
        });

        return contains;
    })    
    .addClass('markedForRemoval')
    .next().addClass('markedForRemoval')
    .next().addClass('markedForRemoval'); 

     $('table#data').find('.markedForRemoval').remove();
});