Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i am using javascript to print a table
how can add background colour to my header
my code is
C#
var r1 = document.createElement("tr");
var h2 = document.createElement("th");
                        var a2 = document.createElement("a");
                       // a2.setAttribute("href","JavaScript:none{0};");
                       // a2.setAttribute("onclick","SortByName()");
                        a2.appendChild(document.createTextNode("DeptID"));
                        h2.appendChild(a2);
                        r1.appendChild(h2);
                         tb.appendChild(r1);



thank you
vara prasad
Posted
Updated 2-Jan-21 23:52pm

I do not really understand what you are doing, but you can change the style of an element like this:

Object.style.backgroundColor="color|inherit|transparent"

http://www.w3schools.com/jsref/prop_style_backgroundcolor.asp[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900