检查表格行单元格中的内容 [英] Check a table row cell for contents
本文介绍了检查表格行单元格中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用jQuery检查表的每个表行中的第二个单元格是否包含任何文本,如果第二个单元格不包含任何文本,则将表行设置为显示:none;
I want to use jQuery to check if the 2nd cell in each table row of a table contains any text, if the 2nd cell doesn't contain any text then set the table row to display: none;
解决此问题的最佳方法是什么?
Whats the best way to go about this?
HTML:
<table id="results">
<tr>
<td>Results</td>
<td>1000</td>
</tr>
<tr>
<td>Description</td>
<td></td> <!-- This cell is empty so hide row -->
</tr>
<tr>
<td>Time/Date</td>
<td>14:03 22/01/12</td>
</tr>
</table>
推荐答案
看看:empty选择器:
$('table tr').has('td:empty:nth-child(2)').hide()
这篇关于检查表格行单元格中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文