views:

82

answers:

4

Is it possible to change the background color of HTML header text in JavaScript?

Edited: oops - i did forget to add that is it header text in jqGrid.. i'm sorry about that..

A: 

Use jQuery. $("h1").css({backgroundColor:"red"})

Júlio Santos
jQuery is not needed.
rchern
I know. But it's way cooler.
Júlio Santos
+3  A: 

jQuery is not needed, you can do this with regular JavaScript.

document.getElementById("headerID").style.backgroundColor = "#FF0000";
rchern
(any particular reason why the square-bracket property accessor?)
bobince
Oy, I was originally thinking in terms of `background-color` and when I got rid of the dash I didn't remove the braces.
rchern