Javascript 在满足条件时更改表中整行的颜色?
当满足条件时,如何更改表中整行的颜色 例如,是否返回失败?把整排都弄红Javascript 在满足条件时更改表中整行的颜色?,javascript,php,html,css,sql,Javascript,Php,Html,Css,Sql,当满足条件时,如何更改表中整行的颜色 例如,是否返回失败?把整排都弄红 <tr> <!-- Disk Space Available --> <td class="tg-yw4l">ld</td> <td class="tg-yw4l"> <?php if ($ld_status == 0) {
<tr> <!-- Disk Space Available -->
<td class="tg-yw4l">ld</td>
<td class="tg-yw4l">
<?php
if ($ld_status == 0) {
echo 'SUCCESS';
} else if ($ld_status == 1) {
echo 'WARNING';
} else {
echo 'FAILURE';
}
?>
</td>
ld
您可以使用PHP生成tr类,然后在css中更改每个类的样式 CSS
.success{
background-color: green;
}
.warning{
background-color: yellow;
}
.failure{
background-color: red;
}
HTML
<tr class=" <?php
if ($ld_status == 0) {
echo 'success';
} else if ($ld_status == 1) {
echo 'warning';
} else {
echo 'failure';
}
?>">
<td class="tg-yw4l">ld</td>
<td class="tg-yw4l">
<?php
if ($ld_status == 0) {
echo 'SUCCESS';
} else if ($ld_status == 1) {
echo 'WARNING';
} else {
echo 'FAILURE';
}
?>
</td>
您可以使用PHP生成tr的类,然后在css中更改每个类的样式 CSS
.success{
background-color: green;
}
.warning{
background-color: yellow;
}
.failure{
background-color: red;
}
HTML
<tr class=" <?php
if ($ld_status == 0) {
echo 'success';
} else if ($ld_status == 1) {
echo 'warning';
} else {
echo 'failure';
}
?>">
<td class="tg-yw4l">ld</td>
<td class="tg-yw4l">
<?php
if ($ld_status == 0) {
echo 'SUCCESS';
} else if ($ld_status == 1) {
echo 'WARNING';
} else {
echo 'FAILURE';
}
?>
</td>
试试这个,它会适合你的情况
<html>
<body>
<?php $ld_status=2; ?>
<table border="1">
<tr style="background:<?php if($ld_status == 0) { echo 'green'; } else if ($ld_status == 1){ echo 'yellow'; } else { echo 'red';}?>;" > <!-- Disk Space Available -->
<td class="tg-yw4l">ld</td>
<td class="tg-yw4l">
<?php
if ($ld_status == 0) {
echo 'SUCCESS';
} else if ($ld_status == 1) {
echo 'WARNING';
} else {
echo 'FAILURE';
}
?>
</td>
</table>
</html>
试试这个,它会适合你的情况
<html>
<body>
<?php $ld_status=2; ?>
<table border="1">
<tr style="background:<?php if($ld_status == 0) { echo 'green'; } else if ($ld_status == 1){ echo 'yellow'; } else { echo 'red';}?>;" > <!-- Disk Space Available -->
<td class="tg-yw4l">ld</td>
<td class="tg-yw4l">
<?php
if ($ld_status == 0) {
echo 'SUCCESS';
} else if ($ld_status == 1) {
echo 'WARNING';
} else {
echo 'FAILURE';
}
?>
</td>
</table>
</html>
使用
标记的bgcolor属性。@DanBracuk(不完全知道是否在曲线前面)警告不要使用bgcolor
属性。使用
标记的bgcolor属性。@DanBracuk(不完全知道是否在曲线前面)警告不要使用bgcolor
属性。