jquery - how to hide the whole table if there is only 1 row -
i have illustration table below, sometime has content , sometime doesn't.
how utilize jquery, if there no td (or there 1 row of tr) hide whole table?
example 1: <table> <tr><th>some title</th></tr> </table> illustration 2: <table> <tr><th>some title</th></tr> <tr><td>some content</td></tr> </table> i tried, doesn't seem working.
$('table').each(function() { if ($(this).find('td:empty').length) $(this).remove(); });
change this:
js
$('table').each(function() { if($(this).find('tr').children("td").length < 1) { $(this).hide(); } }); fiddle
you want hide table? if yes suggest utilize hide() cause remove(), removes element dom.
jquery html-table
No comments:
Post a Comment