我有以下标记,其中有 SPAN >> Table >> TR >> TD
:-
现在我想指定使用 css 或 jquery 删除 TR,它的 TD 在 <nobr>
中包含单词“Question”标签。那么任何人都可以告诉我该怎么做吗?谢谢
最佳答案
您可以使用 filter比较 <nobr>
的精确文本元素,然后删除最近的 <tr>
$("span table tr td nobr").filter(function() {
return $(this).text() === "Question";
}).closest("tr").remove();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span>
<table>
<tr>
<td>
<h3>
<nobr>Question</nobr>
</h3>
</td>
</tr>
<tr>
<td>
Untouched
</td>
</tr>
</table>
</span>
关于javascript - 如何删除具有包含特定文本的 TD 的 TR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31937653/