How to do a mouseover effect?
Hi,
I have a set of buttons on my webpage, which I'd like to sort of, brighten, if the mouse moves over them. How would I do this in Javascript? Apologies for the absolutely *newbie* question, but I just don't know how to do this. Thanks. |
not quite what yer looking for but a starting point perhaps
the following is code to collapse a div but gives you the basic idea of how to modify css attributes with javascript perhaps create a brigtenbutton.js with element.bgcolor or something like that (function bright pick a brighter color function dim pick the original color Code:
function brighten() { then in the <head> section put Code:
<script type="text/javascript" src="brigtenbutton.js"></script> |
Quote:
http://www.groan-zone.net/jscript/mouseover.html I did something like this really quick on one of my web pages: Code:
<a href="/cgi-bin/pages/get?view=lusus"> |
Does it have to be javascript? Anything wrong with using css?
|
How would you do it in CSS?
|
The menu links on here are done in css - http://www.h-baa.net/.
Basically you have an image which consists of two images, one above the other and make it so only one is visible as the background and then on the link hover psuedoclass you shift the image up by x pixels to show the other part of the image. It just involves far less code, no image pre-loading etc and is a lot easier to understand! :) Here is some example code from the website above for the nav links: Code:
<ul> and the css Code:
#nav_bar a.default:link, a.default:visited { |
CSS Method
I fully support this method. The code is a lot cleaner and not having to deal with image pre-loading is a definite advantage.
|
All times are GMT -5. The time now is 09:36 PM. |