[thelist] A JavaScript question

jsWalter jsWalter at torres.ws
Sat Sep 20 00:00:36 CDT 2003


> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org]On Behalf Of
> john at johnallsopp.co.uk
> Sent: Friday, September 19, 2003 3:08 PM
> To: thelist at lists.evolt.org
> Subject: [thelist] A JavaScript question


> ... <a href="" class="menuText" onMouseOver=
> "document.getElementById('menu11').style.background-color = '#FFFFFF';">

> Of course, it doesn't work.

What you have is a cross of Cascading Style Sheets syntax and JavaScript
Syntax.

background-color is css syntax

backgroundColor is JS syntax

Here is a general rule I discovered...

<tip type="JavaScript CSS" author="Walter Torres">
    Many CSS style names use a hyphen. To use them in JS,
    the "-" character is omitted, and the character following
    it is capitalized.

      In CSS                      In JavaScript
        background-color            backgroundColor
        font-size                   fontSize
        border-width                borderWidth
</tip>

See how this works for you.

Walter




More information about the thelist mailing list