PDA

View Full Version : changing background color thru javascript


Hardeep_S
04-25-2005, 04:12 AM
hi.
when i try to use this

document.getElementById(n).style.background-color = "red";

i get a javascript error

can anyone tell me another way to change the background color

this object is a textbox

coothead
04-25-2005, 04:39 AM
Hi there Hardeep_S,

this requires the use of Camel Case (http://www.google.co.uk/search?hl=en&q=camel+case&btnG=Google+Search&meta=). :)

So that...
document.getElementById(n).style.background-color = "red";
...becomes...
document.getElementById(n).style.backgroundColor = "red";

coothead