Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Applying css via javascript

Status
Not open for further replies.
Joined
Jun 5, 2006
Messages
28
Location
US
I have the following code:
<a onmousedown='test();' onmousover=''><img src='button.gif'/></a>

I want to place some code in the onmouseover to apply the following css style to to the image when a user mouses over the image.

cursor:hand;
filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1, xray=0, mirror=0, invert=0, opacity=1, rotation=0);

Thanks.
 
Put the style into a named class and use;

Code:
onmouseover="document.getElementById(this.id).className = "WhatEverNameYouGaveToTheClass";



Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
You can use css for all this. You can do:

:hover for onmouseover
:link and :visited for onmouseout
and
:active for onmousedown
also
:focus might be an alternative for onmousedown, depending on how you want the script to behave.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top