Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-01-2012, 05:08 PM   PM User | #1
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
Swap multiple images on "hover over TEXT"

Hello,
I am trying to do an image swap when hovering over "TEXT" links.
For instance, I would like to first have a "mainpic" in a div that would be replaced by either image 1,2 or 3 (depending on if you are hovering over"text link 1,2 or 3).

I would use normal rollover "image" swaps, but would prefer to have the "trigger" to be "text" (for SEO reasons).

I am just getting familiar with javascript, but do not even know where to begin!
I have read multiple forum entries throught google, but could not find any where I could have "multiple" text links.

I would so much appreciate it if anyone could please point me in a direction. Sincerely, Buffmin
Buffmin is offline   Reply With Quote
Old 03-01-2012, 05:47 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,100
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Try this:-

Code:
<img id = "myImage" src = "default.jpg">
<br><br>

<a href = javascript:void(0); onmouseover = "document.getElementById('myImage').src = 'One.jpg' ">Link one</a> &nbsp &nbsp

<a href =  javascript:void(0); onmouseover = "document.getElementById('myImage').src = 'Two.jpg' ">Link two</a> &nbsp &nbsp

<a href =  javascript:void(0);  onmouseover = "document.getElementById('myImage').src = 'Three.jpg' ">Link three</a>
You can add onmouseout if you wish to revert to the default.


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
Buffmin (03-01-2012)
Old 03-01-2012, 06:14 PM   PM User | #3
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
Thank you Philip.
Looking easy. Now I assume I have to add some type of getelementById script code in the head section? Sorry, I am new to javascript.
Buffmin is offline   Reply With Quote
Old 03-01-2012, 07:07 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,100
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by Buffmin View Post
Thank you Philip.
Looking easy. Now I assume I have to add some type of getelementById script code in the head section? Sorry, I am new to javascript.
No. Why? The code is complete.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
Buffmin (03-01-2012)
Old 03-01-2012, 07:31 PM   PM User | #5
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
Philip,
You are correct! Thank you very much! Buffmin
Buffmin is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:40 AM.


Advertisement
Log in to turn off these ads.