Je veux vérifier si un corps de table (tbody
) est vide en utilisant jQuery. Jusqu'à présent, je l'ai essayé quelque chose comme:Vérifie si un élément est vide après avoir utilisé .append
$("#searchTable tbody").is(":empty")
Mais cela ne fonctionne pas. D'autres idées?
HTML Exemple
<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>
Je veux vérifier si quelque chose a été ajouté à tbody; sinon, alors alerter quelque chose.
En quoi cela ne fonctionne-t-il pas? Pourrions-nous voir un échantillon du HTML? – Matchu