Forum Moderators: open

Message Too Old, No Replies

Replace style attribute for a div

newbie, be gentle

         

brotherhood of LAN

11:43 am on May 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



javascript looks vaguely familiar and I'm ok with regex, though could'nt find sometihng related to this on the web.

<div name="a" style="background-color:#000" onhover"replace_style()"></div>

How would I reference the style tag in order to replace it (or specifically the bgcolour attribute here), I just want to change the colour of it upon hovering.

Alternative Future

11:58 am on May 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<div name="a" style="background-color:#000" onMouseOver="this.style.background='#ff0'" onMouseOut="this.style.background='#000'"></div>

Is this what you are trying to get?

-George

brotherhood of LAN

12:04 pm on May 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That would be it indeed, thanks much :)

bruhaha

12:36 pm on May 18, 2004 (gmt 0)

10+ Year Member



George's suggestion is perfect for changing the value of a single property, but if you happen to want to make more changes to the style, you might instead change the class:

<div name="a" class="plain"
onMouseOver="this.className='special'" onMouseOut="this.className='plain'">{whatever)</div>

Of course, you must declare your styles (in the head or a stylesheet):

.plain {background-color:#000; color:#fff; font-weight:bold;}
.special {background-color:#ff0; color:#000;}

brotherhood of LAN

1:03 pm on May 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



aha, the picture becomes clearer. I'm beginning to get an idea of the "layers" of the document object "thingie" :)

I've ordered javascript the definitive guide, though if either of you could sticky a preferred javascript tutorial id be much obliged.

Alternative Future

1:07 pm on May 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>I've ordered javascript the definitive guide

I have many books on the subject, but, none beat the one mentioned above for learning and using as a bible.

-George

Bernard Marx

2:05 pm on May 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IMHO, books are always better, if you have the cash. Somehow, I can absorb a book in a more relaxed fashion than reading from a screen. Yet, electronic versions of the same thing can offer benefits [bookmarks, searchability, tree menus]..
..and they can be free.

A number of authors have agreements with their publishers to allow them to publish their books (or earlier editions) on the Web. If you have Windows, the Compiled Help File (.chm) format is just dandy.

Hunt around Google with the addition: filetype:chm
eg javascript filetype:chm

Goodman's "Definitive Guide" (4th ed) is one of the things you'll quickly find.
Get hold of Microsoft's JScript5.5 documentation too. (There is a 5.6, but I always find an error in it)

warning CHM files probably have greater privileges on your PC. Who knows if there's some evil weirdo baiting his hook and waiting to catch you. I always explore up through the directory hierarchy where a chm file is situated, just to see if the site looks kosher, and perhaps Google it's keywords against "virus", to see if anything comes up. So far, my PC'ssS ABsoluteLy
f
I
N
e.