posted 19 years ago
Hi,
I'm looking for a way to dynamically change the color of an HTML element using CSS and Javascript, by changing an element's current RGB values. At the moment, I'm setting the color of an element which has an id of "tab1" with the line:
document.getElementById("tab1").style.backgroundColor="#D6B20A";
but then, if I do
alert(document.getElementById("tab1").style.backgroundColor)
instead of being presented with "#D6B20A", I get "rgb(214, 178, 10)".
It would be fine if I could set the red, green and blue attributes separately, or if I just had the hexadecimal code to change, but at the moment I seem to have a mixture of both, which is not making things easy.
Is there some way I can work with either hexadecimal codes, or individual RGB values, but not both?
Thanks for any help provided.
Graham.
[ August 09, 2004: Message edited by: Graham Clark ]