I have a list of links (a text menu), and I need to change an image in other area when each link is hovered...
the images need to be showed in the same place, lets say a 100x100 area at right... any idea to achieve this?
can each link have the src of the images? no idea how to do it :(
Given the following HTML:
Use the following JavaScript (with jQuery):
If its not semantic, and only for presentation, I would use classes and CSS.
MARKUP
CSS
Not a complete answer, but this will guide you to the real solution.
Assume that each link holds the href of the image to be shown and is identifiable by class, say
link-image
. Further, let's say the display area is set up with a fixed id,imageDisplay
.You might actually want to use the hoverIntent plugin to prevent flashing as the mouse moves over the links.
Normally, you'd couple this with a click handler on the links that disables the default link behavior.
Note that you could simply chain the click handler onto the hover handler.
You could store the src of the image in the rel tag on the a?
Then use elcuco's solution but with a minor change.