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



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

Answer / Syed Taqi Raza

To change the style or class of an HTML element with JavaScript, you can use the dot notation to access the element and modify its style or class properties. For example: document.getElementById("elementID").className = "newClass"; or document.getElementById("elementID").style.propertyName = "value"

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More JavaScript Interview Questions

What is the way to get the status of a CheckBox?

1 Answers  


Who is the world famous hacker?

1 Answers  


Is it possible to break javascript code into several lines?

1 Answers  


Write the point of difference between web-garden and a web-farm?

1 Answers  


What is the difference between let, const, and var?

1 Answers  


What is this keyword?

9 Answers   Cognizant, Infosys, Satyam,


What is client side programming?

1 Answers  


Which built-in method returns the index within the calling string object of the first occurrence of the specified value?

1 Answers  


What is difference between ajax and javascript?

1 Answers  


how to create a moving div?

1 Answers  


Explain what is javascript? List some data types supported by javascript?

1 Answers  


What is unobtrusive javascript? How to add behavior to an element using javascript?

1 Answers  


Categories