Image swap
Does anyone know if there is a way to get an image swap without using Javascript?
In other words, could I set it up so when I hover over a link, an image will change to another one in HTML, CSS, or PHP?
Does anyone know if there is a way to get an image swap without using Javascript?
In other words, could I set it up so when I hover over a link, an image will change to another one in HTML, CSS, or PHP?
Megan posted this at 13:58 — 23rd March 2009.
She has: 11,421 posts
Joined: Jun 1999
Yes, there is no need to use javascript for a simple image swap now. All you need is the css :hover pseudo-class. Put your images in as backgrounds, and change them with :hover.
Or did you want to remotely change an image on a different part of a page? I might have seen a CSS example of that somewhere ...
Megan
Connect with us on Facebook!
decibel.places posted this at 17:08 — 23rd March 2009.
He has: 1,494 posts
Joined: Jun 2008
You can also use onmouseover/onmouseoff in the tag to change the image or background image source - still using Javascript but you don't need to place code anywhere but the element.
<img src="plainimg.jpg" onmouseover="this.src='overimg.jpg'" onmmouseoff="this.src='plainimg.jpg'" />
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.