Reputation: 71
I want to hide a tr when one of it's td contains a part of the keyword "Aufruestung".
E.g. one td has the text "APL Aufruestung 10", I want to find it and hide the complete tr - but just the first tr, not all the parents. My first try doesn't work at all, I think i have to do something with RegEx to find all the tr's with "Aufruestung"? I'm not sure and a newbie to jQuery...
jQuery('td:contains("Aufruestung"))').closest('tr').hide()
Upvotes: 1
Views: 886
Reputation: 6156
Try this
$("td").each(function() {
var str = 'Aufruestung';
var txt = $(this).html();
alert(txt); // to cross verify
if (/Aufruestung/i.test(txt)){
alert('String Contains Word');
} else {
alert('String Does not contains word');
}
});
Upvotes: 1
Reputation: 82231
You have typo in your code. extra )
is added in it. also you can check for contains is tr rather than in tds:
jQuery('tr:contains(Aufruestung)').hide()
Upvotes: 0