Expert Developer JavaScript Question:
Download Questions PDF

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

Expert JavaScript Developer Interview Question
Expert JavaScript Developer Interview Question

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 Interview Questions And Answers PDF

Previous QuestionNext Question
Write the code for adding new elements dynamically?Explain how to detect the operating system on the client machine?