我有一张桌子有多个<tr>
.他们中的一些人为他们设置了课程.
我<tr>
没有课,有class="Failure"
和有class="Error"
(这是一个JUnit html报告).
我想在页面上放一个按钮,然后单击它以删除所有带有已定义类的tr(失败和错误).
我尝试过这样的事情:
$("tr").remove(":contains('Failure')");
Run Code Online (Sandbox Code Playgroud)
谢谢
如果您的意思是上课Failure
或 Error
,请执行以下操作:
$("tr.Failure,tr.Error").remove(); // remove those with either
Run Code Online (Sandbox Code Playgroud)
如果你的意思是两个类:
$("tr.Failure.Error").remove(); // remove those with both
Run Code Online (Sandbox Code Playgroud)
对于这两种情况,您可以将选择器移动到.remove()
原来的位置:
$("tr").remove(".Failure,.Error"); // remove those with either
Run Code Online (Sandbox Code Playgroud)
要么:
$("tr").remove(".Failure.Error"); // remove those with both
Run Code Online (Sandbox Code Playgroud)