I’d like to check for empty TDs (classes a-h only) and if all are empty, then I’d like to hide the parent TR. The issues I’m running into are, my empty TDs contain ” ” I’m not sure how to test for those?
<table>
<tr>
<td class="requirementRight">Requirement</td>
<td class="a"> </td>
<td class="b"> </td>
<td class="c"> </td>
<td class="d"> </td>
<td class="e"> </td>
<td class="f">NOT EMPTY</td>
<td class="g"> </td>
<td class="h"> </td>
</tr>
<tr>
<td class="requirementRight">Requirement</td>
<td class="a"> </td>
<td class="b"> </td>
<td class="c"> </td>
<td class="d"> </td>
<td class="e"> </td>
<td class="f"> </td>
<td class="g"> </td>
<td class="h"> </td>
</tr>
if ( $('td.a:empty, td.b:empty, td.c:empty, td.d:empty, td.e:empty, td.f:empty, td.g:empty, td.h:empty') ) {
// hide the parent tr
}
“If Empty” is not clear, since in your example, they are filled with “nbsp”. This is the reason why I made a function called isEmpty() so you can define your custom rules in there. Since you didn’t want requirementRight, I put td:not(.requirementRight). This is not the correct way to do it.
The correct way to do it, would be to put a second class on a-h, such as
So we can call tr.find(tr.checkempty)..
Anyway, here’s the code!
Working Example: http://jsfiddle.net/FeQ7h/7/