jQuery - 查找包含特定文本的表格单元格的表格行 [英] jQuery - find table row containing table cell containing specific text
本文介绍了jQuery - 查找包含特定文本的表格单元格的表格行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个 tr
元素,它包含一个包含特定文本的 td
元素。 td
将包含该文本,只包含该文本(所以我需要 text ='foo'
不是 text包含'foo'
逻辑)。
I need to get a tr
element which contains a td
element which contains specific text. The td
will contain that text and only that text (so I need text = 'foo'
not text contains 'foo'
logic).
所以我需要等同于以下的伪jQuery:
So I need the equivalent of the following 'pseudo jQuery':
var tableRow = $(table td[text = 'foo']).parent('tr');
任何人都可以提供正确的语法?
Can anyone provide the correct syntax?
推荐答案
您可以使用 filter()来做到这一点: / p>
You can use filter() to do that:
var tableRow = $("td").filter(function() {
return $(this).text() == "foo";
}).closest("tr");
这篇关于jQuery - 查找包含特定文本的表格单元格的表格行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文