Easiest way to HTML a hover over image

Costello

Headmaster
Administrator
Joined
Oct 24, 2002
Messages
14,154
Trophies
4
XP
19,020
CODE




Move the mouse over the image:




click here to test the code:
http://gbatemp.net/up/test.html

how does it work?
- two images ("reg.jpg" and "test.png") are loaded but hidden/invisible, with height=0 and width=0
- by default, test.png is displayed
- when the mouse moves over the image, test.png is replaced by reg.jpg
- when the mouse moves out of the image, test.png comes back
 

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,746
Trophies
4
Age
45
Location
Engine room, learning
XP
15,563
Country
France
I was waiting for your post Costello
wink.gif



It's better than what I would have give him (something with function swap{})
It even manage the preload image with width/height=0.

I feel like an apprentice
shy.gif
 
General chit-chat
Help Users
  • No one is chatting at the moment.
    Skelletonike @ Skelletonike: 1H left, such a slow week.