我輸出該表:如果沒有TR,隱藏表
<table class="table-example">
<thead>
<tr>
<th scope="col">Location</th>
<th scope="col">Description</th>
<th scope="col">Status</th>
<th scope="col">Eta Fix</th>
</tr>
</thead>
<tbody></tbody>
</table>
我需要整個表不顯示,如果是TBODY空如上
使用上這個變化的嘗試:
$(function(){
if ($('.table-example > tbody').length == 0){
$('.table-example).hide();
}
});
我在做什麼錯?
你找TBODY元素有數量.table-example而不是tr元素。將選擇器更改爲「.table-example> tbody tr」 – SidTheBeard