我有一个包含几行的表格,每行包含两列,第一列将包含标题,第二列将包含相应的值。有时,右侧的单元格可能没有值,因此它不会只有标题是有意义的..没有值(value)..我可以将标题隐藏在右边没有值(value)的左侧单元格或整行本身。
我想出了这个,但它不起作用..
$('.EventDetail tr').each(function(){
if(!$('td:not(:empty)',this).length)
$(this).hide();
});
这是表格。我想知道标签是否有所作为。或者其中一个有类(class)而另一个没有..这会导致它不起作用吗?
<table cellpadding="10" class ="EventDetail">
<tr>
<td class="TableFields"><em>Who Should Enroll?:</em></td>
<td>Everyone 18 and older who would like to attend</td>
</tr>
<tr>
<td class="TableFields"><em>Handicapped Access:</em></td>
<td>Yes</td>
</tr>
<tr>
<td class="TableFields"><em>Parking Notes:</em></td>
<td></td>
</tr>
<tr>
<td class="TableFields"><em>Instructor:</em></td>
<td>John Filler</td>
</tr>
</table>
所以没有 parking 票信息,所以我想隐藏包含标题“ parking 票”的左侧单元格。
最佳答案
关于javascript - 隐藏包含空列的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8978812/