javascript - How to change text colour based on conditions?
872
Changing the colour of the marks obtained by a student - if < 40 then red else black.
I have a table in a PHP file displaying marks obtained in various subjects. Below 40 marks should be shown in red.
echo "<td>".$res['marks1i']."</td>";
echo "<td>".$res['marks1e']."</td>";
echo "<td>".$res['marks2i']."</td>";
echo "<td>".$res['marks2e']."</td>";
echo "<td>".$res['marks3i']."</td>";
echo "<td>".$res['marks3e']."</td>";
Answer
Solution:
Using Javascript:
You can add a class name to each of the
td
's that have marks (say 'marks'), then:Answer
Solution:
Would that solve your problem?: