Answers for "javascript change table row color based on value"

0

javascript change table row color based on value

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";           
 }
Posted by: Guest on July-02-2021

Code answers related to "javascript change table row color based on value"

Code answers related to "Javascript"

Browse Popular Code Answers by Language