Forum Moderators: not2easy

Message Too Old, No Replies

changing "hover" property using javascript

Can I change the "hover" properties for an element using JavaScript?

         

Christoffer

11:52 am on Sep 15, 2003 (gmt 0)



I'm trying to build a dynamic style edtitor with "real time" editing. This includes JS scripts to change the properties of the elements as selections are made in a form. E.g. you click in the checkbox for bold text and the sample text turns bold.

I use the code (for IE5.5/Win):
eval( tag + '.style.' + type + ' = "' + newValue + '"' );

e.g. eval("H1.style.fontWeight = 'bold');

I would like to do the same for the a:hover case, but I cannot figure out how or where to include the "hover" in the statement. I haven't been able to find anything usefull in the JS documentation, so I don't know if it's possible at all.

Any suggestions?

One possible work-aroung could be to change the properties of an already defined class (say ".a_hover"), but that doesn't seem to be possible with JS either.

Any suggestions are highly appreciated... :)

BlobFisk

12:39 pm on Sep 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, Christoffer!

The onmouseover event handler would be the one to use for your hover state...

nrobidoux

12:13 am on Feb 14, 2008 (gmt 0)

10+ Year Member



Wow.... I had my brain trying to figure this out. It would've taken me forever. Thanks BlobFisk

jakecoogle

2:48 pm on Feb 17, 2008 (gmt 0)

10+ Year Member



I'm not sure if this is helpful, but you could make a second class for the new state and use javascript to chance the class: [webmasterworld.com...]