HTMLElement style
JavaScript -> Objekty -> HTMLElement Object -> HTMLElement style
Popis
Pomocou vlastnosti style môžeme meniť CSS vlastnosti objektu.
Príklad
Keď chceme naraz meniť viac hodnôt, môžeme použiť metódu setAttribute:
var elem = document.getElementById("elem");
elem.setAttribute("style","width: 500px; background-color: yellow;");
elem.setAttribute("style","width: 500px; background-color: yellow;");
Niektoré vlastnosti v CSS a ich ekvivalenty v JavaScripte
| Css Property | JavaScript Equivalent |
|---|---|
| background | background |
| background-color | backgroundColor |
| background-image | backgroundImage |
| border | border |
| clear | clear |
| color | color |
| display | display |
| float | cssFloat |
| Font-family | fontFamily |
| Font-size | fontSize |
| Font-weight | fontWeight |
| height | height |
| Left | left |
| list-style | listStyle |
| list-style-image | listStyleImage |
| margin | margin |
| Text-decoration | textDecoration |
| vertical-align | verticalAlign |
| Visibility | visibility |
| Width | width |
| z-index | zIndex |