
| Navigation |
|
|
 |
| Latest Additions |
|
|
 |
| Links |
|
 |
| Recommendations |
|
 |
|
Change CSS Property via javaScript
By: Lee A. Shurie |
| Subject: |
CSS via JavaScript |
| Language: |
JavaScript |
| Rating: |
 Rated 13 times. Rate or review this item: 1 2 3 4 5 Read Reviews
|
Information Typically, CSS attributes are represented as properties in a style sheet. They may also be coded directly into an html tag. For example: <div Style="font-weight:bold; color:0088dd;">some text here</div>.
But how can you set or change these attributes via JavaScript?
For non hyphenated attributes, the property is identical. So your Javascript could look like this:
onMouseover="this.style.color='#0000ff'"
For hyphenated attributes, drop the hyphen and capitalize the first letter following it. For example: to manipulate the "font-weight" CSS property your JavaScript might look like this:
onMouseover="this.style.fontWeight='#fffff'"
Examples:
color = color
padding = padding
font-weight = fontWeight
background-color = backgroundColor
border-bottom-width = borderBottomWidth |
Keywords:javascript css style stylesheet |
|

|