JavaScript - Changing CSS JAVASCRIPT

JavaScript - Changing CSS  

JavaScript - Changing CSS

JavaScript HTML DOM - Changing CSS

To change the style of an HTML element, use this syntax:

document.getElementById(id) = new style

The following example changes the style of a <p> element.




<p id="p2">Hello World!</p>

document.getElementById("p2").style.color = "blue";

<p>The paragraph above was changed by a script.</p>


Download free E-book of JAVASCRIPT

Learn Programming for Free

Join Programmers Community on Telegram

Talk with Experienced Programmers

Just drop a message, we will solve your queries