Expert Developer JavaScript Question:

How can the style/class of an element be changed?

Tweet Share WhatsApp

Answer:

It can be done in the following way:

JavaScript

document.getElementById("myText").style.fontSize = "20?;
or
document.getElementById("myText").className = "anyclass";

Download Expert JavaScript Developer PDF Read All 150 Expert JavaScript Developer Questions
Previous QuestionNext Question
Write the code for adding new elements dynamically?Explain how to detect the operating system on the client machine?