javascript - Automatic row highlighting

one text

Solution:

It's a simple case of using an if statement, or, as in my example below, shortening that to a ternary operator

"<td class='a'".($row['masalah'] == "KIV" ? "style='background-color:red'" : "").">"

N.B. If you want to do it on the whole row you'll need to set the style on the enclosing <tr> rather than a single <td>, but the basic approach is the same. (Your example code doesn't contain any <tr>s but I assume you must have omitted them for brevity.)

Source