Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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";           
 }
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript change data attribute value 
Javascript :: regex check is valid ip 
Javascript :: Component should be written as a pure function 
Javascript :: javascript set and get cookie 
Javascript :: how to delete first key in hashmap in javascript 
Javascript :: regExp for finding a first letter and last letter in a string 
Javascript :: javascript reverse string without reverse method 
Javascript :: website link regex stackoverflow 
Javascript :: javascript tan 
Javascript :: how to clear innerhtml in javascript 
Javascript :: how to check if you click something in javascript 
Javascript :: scroll to bottom 
Javascript :: javascript get random array item 
Javascript :: stop a setinterval 
Javascript :: js alert yes no 
Javascript :: history.push.hook 
Javascript :: ajaxcall 
Javascript :: react js font awesome icon not rendering 
Javascript :: if checkbox is checked 
Javascript :: remove add event listener jquery 
Javascript :: javascript stringify an object 
Javascript :: datalist example 
Javascript :: javascript play sound on click 
Javascript :: how to create a new react native project 
Javascript :: how to replace commas with nothing in javascript 
Javascript :: js ask before close 
Javascript :: ajax each function 
Javascript :: javascript checked 
Javascript :: javascript to convert rgb to hsl 
Javascript :: javascript clear table body 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =