📌  相关文章
📜  javascript 根据值更改表格行颜色 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:17.806000             🧑  作者: Mango

代码示例1
var rows = document.getElementById("trans_separate").getElementsByTagName("tbody")
  [0].getElementsByTagName("tr");

    // loops through each row
    for (i = 0; i < rows.length; i++) {cells = rows[i].getElementsByTagName('td');

            if (cells[0].innerHTML == 'R')
                rows[i].className = "red";

            if (cells[0].innerHTML == 'Y')
                rows[i].className = "yellow";           
 }