我想tbody使用jQuery 检查表body()是否为空.到目前为止,我尝试过类似的东西:
$("#searchTable tbody").is(":empty")
Run Code Online (Sandbox Code Playgroud)
但它不起作用.还有其他想法吗?
HTML示例
<table id="searchTable" cellpadding="0" cellspacing="0" width="100%">
<thead>
<tr>
<th>No.</th>
<th><a href="#">Status</a></th>
<th><a href="#" class="asc">Category</a></th>
<th><a href="#" class="desc">Title</a></th>
<th><a href="#" class="desc">Last Used</a></th>
<th><a href="#" class="desc">URL</a></th>
<th style="width: 96px;">Actions</th>
</tr>
</thead>
<tbody></tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
所以我想检查tbody中是否附加了某些内容; 如果没有,那么提醒一些事情.
你可以试试像
$('#searchTable tbody').children().length;
Run Code Online (Sandbox Code Playgroud)
如果tbody为空(没有孩子),则为0.
| 归档时间: |
|
| 查看次数: |
6160 次 |
| 最近记录: |