[英]how to get first table row “<td></td>” text which are visible using jquery
[英]jQuery if specific text exists in table hide first td of his row
我想知道如何解决以下问题:我有一个包含几行的表。 我想要的是:检查是否存在特定文本,如果这样,则仅 “隐藏” 该行的第一个TD。
这是我的工作jsfiddle
到目前为止,这是我的JS代码:
var $existingText = $('#myTable');
if ($existingText.length); {
if ($existingText.text().replace(/\s+/g, '') === "expired") {
$(this).parents("tr td:first-child").css('display','none');
}
};
这将在这里工作
$existingText.find('tr').each(function(){
if($(this).text().indexOf('expired') > -1){
$(this).find('td:first-child').hide()
}
})
这是工作:
$("tr:has(td:contains('expired'))").each(function () {
$(this).find("td:first").hide();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.