Main Content

Javascript - move cursor over image to change a different image.

Archive - Originally posted on "The Horse's Mouth" - 2009-04-16 15:06:19 - Graham Ellis

Let's imagine that you have an image which is a map on your web page, and as you move over the map you want another image (elsewhere on the page) to change to show the place you're pointing too. Well - it can be done with Javascript, but it's not necessarily easy to find a simple example online ... which is probably why one of my customers asked me how to do it.

Try it out at http://www.wellho.net/demo/terry2.html and see the source code at http://www.wellho.net/resources/ex.php4?item=w602/terry2.html.

If you look at the source code, you'll find a lot of repeated code - not a good idea in the long term, but it will help you see what I have done and how I have done it.

P.S. The original question wasn't about maps and places - it was about a football team and showing pictures of their favourite foods. Yes, it should work for them too!