We can add, remove or change CSS property values with JavaScript via an element's style property.

Step 1

Get the element via ID or class.


var element = document.getElementById("ID_Name");

Step 2

Change the CSS property.


element.style.opacity = 1;
element.style.fontFamily = 'sans-serif';

The property name changes (not completely!) when we use JavaScript. So, font-family becomes fontFamily.

0 Comments

Leave a reply

Your email address will not be published. required fields are marked *