JavaScript can be used to change the style of an HTML element:
Examples
Change the style of the current element
How to change the style of an element using the this object.
Change the style of a specific element
How to change the style of an element using getElementById.
JavaScript, DOM, and CSS
With HTML 4, JavaScript and the HTML DOM can be used to change the style any HTML element.
To change the style the current HTML element, use the statement:
Code:
style.property=new style
or more correctly:
Code:
this.style.property=new style
To change the style of a specific HTML element, use the statement:
Code:
document.getElementById(element_id).style.property=new style