Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

JS table with rows that have alternating colours

function altrows(firstcolor,secondcolor)
{
    var tableElements = document.getElementsByTagName("table") ;
    for(var j = 0; j < tableElements.length; j++)
    {
        var table = tableElements[j] ;

        var rows = table.getElementsByTagName("tr") ;
        for(var i = 0; i <= rows.length; i++)
        {
            if(i%2==0){
                rows[i].style.backgroundColor = firstcolor ;
            }
            else{
                rows[i].style.backgroundColor = secondcolor ;
            }
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: show data time &refresh 
Javascript :: on click insert into element time 
Javascript :: js undici fetch stream data 
Javascript :: Move capital letters to the beginning 
Javascript :: string variable 
Javascript :: filter text js 
Javascript :: javascript to jquery code converter online 
Javascript :: nestjs TS2339 
Javascript :: change on id 
Javascript :: Get index of child elements with event listener in JavaScript 
Javascript :: how to put multiple conditions in if statement node .js 
Javascript :: javascript every nested array 
Javascript :: fibonacci sequence array 
Javascript :: js brightness filter 
Javascript :: how to add google map in react js 
Javascript :: reactnative timepicker 
Javascript :: Multiple functions in javascript onclick 
Javascript :: multer 
Javascript :: adding int and string in react props 
Javascript :: get element by id angular 
Javascript :: mvc asp.net partial view from js 
Javascript :: date range picker jquery 
Javascript :: react native fast image webp ios 
Javascript :: angularjs select placeholder 
Javascript :: disable a function javascript 
Javascript :: javascript callback 
Javascript :: React_Weather_APp 
Javascript :: setting up a react environment 
Javascript :: jconfirm button 
Javascript :: check if string javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =