I need to change more than one style attribute for a given element. I know how to change one: document.getElementById(today).style.visibility= "visible";
but am unsure of the syntax for changing more than one e.g. visibility,width, height and font-color.
4 Answers
It's just multiple calls:
document.getElementById(today).style.visibility = "visible";
document.getElementById(today).style.color = "red";
document.getElementById(today).style.height = "5em";
2 Comments
Dave
Awesome thanks. Next trick is one of the attributes that I am changing is font-size but it doesn't seem to like the "-" in document.getElementById(today).style.font-size= "x-small";
Christian C. Salvadó
@Dave, for CSS properties that have contain dashes, you have to remove the dash, and uppercase the next character, i.e.: for
font-size, you should use fontSize.