javascript - How to Hide an image stored in second TD based on the values of table stored in first TD with JQuery? -
i have 2 columns table first td containing table 3 rows of contents , second td image below:-
<table id="mytable" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 10px;"> <table> <tbody> <tr> <td align="left"> wellness , care </td> </tr> <tr> <td align="left"> 630 woodbury drive </td> </tr> <tr> <td align="left"> 641.613.1450 </td> </tr> <tr> <td align="left"> no webaddress </td> </tr> </tbody> </table> </td> <td align="right"> <img src="images/phone.png" class="imgheader" id="imgphone"> </td> </tr> <tr> <td style="padding-top: 10px;"> <table> <tbody> <tr> <td align="left"> hospital </td> </tr> <tr> <td align="left"> n/a </td> </tr> <tr> <td align="left"> 641.613.1451 </td> </tr> <tr> <td align="left"> no webaddress </td> </tr> </tbody> </table> </td> <td align="right"> <img src="images/phone.png" class="imgheader" id="imgphone"> </td> </tr> </tbody> </table>
i trying disable image on second column of row, if value of 1 of td "n/a". stuck @ getting parent tr , going second td something.
my try follows:
$('#mytable tr').each(function () { if ($(this).find("td").text().trim() == "n/a") { var cellindex = $(this).index(); var nexttd = $(this).children('td').eq(1).index(); // stuck here in getting next td } });
any appreciated!!
$('#mytable td:first-child td:contains("n/a")').parents('td').next().find('img').hide();
Comments
Post a Comment