我有一个表格显示数据库中的数据,并且我有一个带有简单算术函数的单元格。 我想隐藏总和为零的整个行(如果$ sold值为零)。根据html表单元格值隐藏行
<input type="button" id="btnHide" Value=" Hide Empty Rows " />
...
<tbody>
\t \t \t <?php }
\t
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$sold=$row['value1']+$row['value2']);
\t { ?>
<tr>
\t \t \t <td><?php echo $row['contract'] ?></td>
\t \t \t <td><?php echo (round($row['value1'], 2)) ?></td>
\t \t \t <td><?php echo (round($row['value2'],2)) ?></td>
\t \t \t <td><?php echo ((round($sold, 2))+0) ?></td>
\t </tr><?php } } ?>
</tbody>
我发现一些代码隐藏所有行,它具有空单元格,但它不是我想要的。 Thx寻求帮助。
$(document).ready(function() {
$("#gdRows td").each(function() {
var cellText = $(this).text();
if ($.trim(cellText) == '') {
$(this).css('background-color', 'cyan');
}
});
$('#btnHide').click(function() {
$("#gdRows tr td").each(function() {
var cell = $.trim($(this).text());
if (cell.length == 0) {
$(this).parent().hide();
}
});
});
$('#btnReset').click(function() {
$("#gdRows tr").each(function() {
$(this).show();
});
});
});