I would like to hide the td containing the image if the image src inside of the td is null.
I tried the following, but it would hide more than just the td i was trying to target:
$('td').each(function() {
if($(this).find('img').attr('src') == "null"){
$(this).css('display', 'none');
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tbody>
<tr>
<td>
<p class="centered">
<label class="wrapable">
<img src="null">
<input name="test" value="1" type="radio">
</label>
</p>
</td>
<td>
<p class="centered">
<label class="wrapable">
<img src="null">
<input name="test" value="1" type="radio">
</label>
</p>
</td>
<td>
<p class="centered">
<label class="wrapable">
<img src="null">
<input name="test" value="1" type="radio">
</label>
</p>
</td>
<td>
<p class="centered">
<label class="wrapable">
<img src="http://lorempixel.com/100/100">
<input name="test" value="1" type="radio">
</label>
</p>
</td>
</tr>
<tbody>
</table>
Any help would be greatly appreciated, still learning :)