i have a table like this in my html page
<table id="mytable">
<tr id="classified">
<td>1</td>
</tr>
<tr id="unclassified">
<td>0</td>
</tr>
</table>
so, on the document.ready i want to check which column has 0 value, if value is o then hide that row,
i have written this code but doesnt seem to work
$(document).ready(function IsValidTableContent() {
$('#mytable tr td').each(function () {
if ($(this).val() == 0) {
$(this).hide();
} else {
$(this).show();
}
});
});
You can locate that
tdwith:contains():Fiddle: http://jsfiddle.net/UCgSL/
Warning:
If you have other cells that contains 0, but aren’t exactly equal to 0,
:containswill include those in the matches as well. This would mean that100or1,000could also show up since those also contain0. If you want only those whose values are0, and nothing else, you should consider using a filter:Fiddle: http://jsfiddle.net/UCgSL/1/
Custom Filter Selector
If using
.filteris too verbose, you could roll your own filter selector:Fiddle: http://jsfiddle.net/UCgSL/2/