[Javascript] How can I change this using CSS
Steve Clason
stevec at topdogstrategy.com
Wed Jul 20 14:05:26 CDT 2005
On 7/20/2005 12:42 PM Roland Dong wrote:
> I have the following working code:
> <div onmouseOver="style.backgroundColor='#FF00FF'; " onmouseOut=
> "style.backgroundColor='#FFFFFF'" class="cat">
>
>
> I want to move background color changing code to CSS. I tried something like
> this:
>
> <div onmouseover: this.className="on" onmouseout:this.className="off"
> class="cat">
>
> in style sheet add:
>
> ................
> .off{ background: #D2D2EC; }
> .on { background: #FFFFFF; }
> .................
>
> However, since there is already a "cat" class, it would override the "cat"
> class.
>
> Any suggestion?
For what it's worth, an element can belong to two classes, e.g.
<div class="red bold">Word</div>
red{color:red}
bold{font-weight:bold}
...and "Word" will be both red and bold. I'm not sure if
this.className="red bold" will work, though.
--
Steve Clason
Web Design and Development
Boulder, Colorado, USA
www.topdogstrategy.com
(303)818-8590
More information about the Javascript
mailing list