Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count of td (table) using jQuery?

<table>
<tbody>
<tr class="row-1 row-first">
<td><div class="inside">Text</div></td>
<td><div class="inside">Text</div></td>
<td><div class="inside">Text</div></td>
</tr>
<tr class="row-2">
<td><div class="inside"></div></td>
<td><div class="inside">Text</div></td>
<td><div class="inside">Text</div></td>
</tr>
<tr class="row-3 row-last">
<td><div class="inside"></div></td>
<td><div class="inside">Text</div></td>
<td><div class="inside">Text</div></td>
</tr>
</tbody>
</table>

That is my HTML.. I want to know the count of td's which does not have an empty div (with class="inside") in jQuery? How do I go about it?

like image 724
Pack Hack Avatar asked Dec 10 '22 08:12

Pack Hack


1 Answers

Something like this, with the has, not, and empty selectors:

$('td:not(:has(div.inside:empty))').length;
like image 52
lonesomeday Avatar answered Dec 26 '22 11:12

lonesomeday