I have a table.and I need to check the table has at-least one value.and if the text in the table named Test set some alert
my table structure is
<table id="chk-table">
<tbody>
<tr>
<td>Check
</td>
</tr>
<tr>
<td>Test
</td>
</tr>
<tr>
<td>Check1
</td>
</tr>
</tbody>
</table>
I tried something tlke
if ($('#chk-table tr').length >0) {
if ($('#chk-table td:contains("Unknown")')) {
alert("Test");
}
}
but when the table has no value the alert is showing Can anyone help?
$('#chk-table td:contains("Unknown")')) always returns a jQuery object; because it returns an object this is a 'truthy' value therefore theifassessment always evaluates totrue.