Changing element part 2
Changing Style
The style of HTML elements can also be changed using JavaScript.
All style attributes can be accessed using the style object of the element.
For example:
The code above changes the text color and width of the div element.
All CSS properties can be set and modified using JavaScript. Just remember, that you cannot use dashes (-) in the property names: these are replaced with camelCase versions, where the compound words begin with a capital letter.
For example: the background-colorproperty should be referred to as backgroundColor.
Comments
Post a Comment