Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery select all rows containing certain text within a td in the row

Tags:

I have a table for which I am attempting to select all rows which have a td containing the text 'Test' and then hide the td with class 'ms-vb-icon' on all the matched rows

I intitally had the code below but this only hide the class on the last matched row

 $("td:contains('test'):last").parent().children(".ms-vb-icon").css("visibility","hidden"); 

So I tried this but its not working...

 $("tr:has(td:contains('test')").each(function(){   (this).children(".ms-vb-icon").css("visibility","hidden");   }); 

Simplified html look like this:

<table> <tbody> <tr> <td class=ms-vb-icon></td> <td></td> <td></td> <td></td> <td></td> <td>test</td> </tr> </tbody> <table> 
like image 713
van Avatar asked Dec 03 '10 01:12

van


1 Answers

Try:

$("tr td:contains('test')").each(function(){   $(this).siblings('td.ms-vb-icon').css("visibility","hidden"); }); 

Demo here.

like image 111
sje397 Avatar answered Sep 19 '22 15:09

sje397