Next in this lesson: Summary
To change many style properties at once, switch the className.
document.getElementById("copytext4").className = "blueArea";
This is example text in a textarea element, id='copytext4'.
Here's how to make it into a function.
function setClassName(objId, className) {
document.getElementById(objId).className = className;
}Click the 'eval' to have JavaScript evaluate the previous and next text (call the function).
setClassName("copytext4", "copytext");
When setClassName is called, the arguments passed are
"copytext4" and
"copytext".
Looking at the function, the parameter objId
will hold the value
"copytext4"
and the parameter className will hold the value
"copytext".