Expert Developer JavaScript Question:
How can the style/class of an element be changed?
Answer:
It can be done in the following way:
JavaScript
document.getElementById("myText").style.fontSize = "20?;
or
document.getElementById("myText").className = "anyclass";
JavaScript
document.getElementById("myText").style.fontSize = "20?;
or
document.getElementById("myText").className = "anyclass";
Previous Question | Next Question |
Write the code for adding new elements dynamically? | Explain how to detect the operating system on the client machine? |