change image display by link class hover

Hello,

I have the following, I want the image to change on hover of the links using either js or css.

<div class="dropper">
<a href="" class="linkone">Link One</a>
<a href="" class="linktwo">Link Two</a>
<a href="" class="linkthree">Link Three</a>
</div>
<div class="imgs">
<img src="/linkone" class="linkoneimg">
<img src="/linktwo" class="linktwoimg">
<img src="/linkthree" class="linkthreeimg">
</div>
LVL 1
movieprodwAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Like this
<!doctype html>
<html>
<head>
<title>Test</title>
<link href="css/bootstrap.css" rel="stylehseet" />
<style type="text/css">
.imgs {
  width: 800px;
}
.imgs img {
  display: none;
  width: 100%;
}
.imgs img:first-child {
  display: block;
}
</style>
</head>
<body>
<div class="dropper">
  <a href="#linkoneimg" class="linkone">Link One</a>
  <a href="#linktwoimg" class="linktwo">Link Two</a>
  <a href="#linkthreeimg" class="linkthree">Link Three</a>
</div>
<div class="imgs">
  <img id="linkoneimg" src="http://jimdo.wpengine.com/wp-content/uploads/2014/01/tree-247122.jpg" class="linkoneimg">
  <img id="linktwoimg" src="http://i.dailymail.co.uk/i/pix/2015/01/06/24730FCA00000578-2898639-Two_giraffes_in_Kenya_appeared_to_be_dancing_as_they_were_photog-a-15_1420546215639.jpg" class="linktwoimg">
  <img id="linkthreeimg" src="http://images.visitcanberra.com.au/images/canberra_hero_image.jpg" class="linkthreeimg">
</div> 
<script src="http://code.jquery.com/jquery.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="js/bootstrap.js"></script>
<script type="text/javascript">
$(function() {
  $('a').hover(function() {
    $('.imgs img').hide();
    $($(this).attr('href')).show();
  });
});
</script>

</body>
</html>

Open in new window

Working sample here http://www.marcorpsa.com/ee/t769.html

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ronak PatelCommented:
Hi movieprodw,

Please refer the attached code sample:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">

	function toggleImg(objId, event)
	{
		//alert(event);
		if(event == "over")
			document.getElementById(objId).src = "Images/refresh.png";
		else
			document.getElementById(objId).src = "Images/bmw.png";
	}

</script>
</head>
<body>
<div class="dropper">
	<a href="#" class="linkone" onmouseover="toggleImg('linkoneimg','over');" onmouseout="toggleImg('linkoneimg','out');">Link One</a>
	<a href="#" class="linktwo" onmouseover="toggleImg('linktwoimg','over');" onmouseout="toggleImg('linktwoimg','out');">Link Two</a>
	<a href="#" class="linkthree" onmouseover="toggleImg('linkthreeimg','over');" onmouseout="toggleImg('linkthreeimg','out');">Link Three</a>
</div>
<div class="imgs">
	<img src="Images/bmw.png" class="linkoneimg" id="linkoneimg">
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<img src="Images/bmw.png" class="linktwoimg" id="linktwoimg">
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<img src="Images/bmw.png" class="linkthreeimg" id="linkthreeimg">
</div> 
</body>
</html>

Open in new window


Hope this helps.

Regards,
Ronak

Q-28676699.zip
movieprodwAuthor Commented:
Thanks guys, they worked out, I ended up using the first one
Julian HansenCommented:
You are welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.