Sun, 2003-11-30 05:43
How can I change styles(background color) via javascript. Example:
document.getElementById("question"+errorQuestions[i]).style.background-color="#CCCC00";
I am trying to change the background color of a div on a questionnaire form, when the user has not answered a particular question. Above example doesn't work for some reason.
Sun, 2003-11-30 06:43
#1
Changing style(background color) via javascript
Hi paCkeTroUTer,
Your pretty close the JavaScript style properties are slightly different to the CSS style properties.
Mostly for the JavaScript version you use lowercase first word and upper case first letter of second word with no space or hyphen.
So background-color becomes backgroundColor.
Hope that helps.
Sun, 2003-11-30 10:46
#2
Changing style(background color) via javascript
Thanks Tony, that works. Didn't know about the syntax of javascript. Do you know of a resource that has a complete manual on JavaScript for me to refer to ?