Reputation: 1
I'm looking all day for solution. I try to make something like these:
sigma-topline2012.com/en-us/topline-2012/bc-5-12/overview.html#highlight
As you can see, when we move the mouse on description on right, then image is changing. Could anybody can help me with these? Thanks!
Upvotes: 0
Views: 35
Reputation: 104
Try this:
<div id="definition1">Definition 1</div>
<div id="definition2">Definition 2</div>
<img id="imageWrapper" src="image1.png" />
Javacript:
$("#definition1").hover(function(){
$('#imageWrapper').attr("src", function(index, attr){
return attr.replace("image1.png", "image2.png");
});
}, function(){
$('#imageWrapper').attr("src", function(index, attr){
return attr.replace("image2.png", "image1.png");
});
});
Upvotes: 0
Reputation: 189
Use jQuery hover
<img id="image" src="http://placekitten.com/g/130/130" />
<ul>
<li data-link="http://placekitten.com/g/150/150">Cat 1</li>
<li data-link="http://placekitten.com/g/151/151">Cat 2</li>
<li data-link="http://placekitten.com/g/152/152">Cat 3</li>
</ul>
$(document).ready(function(){
var img = $('#image');
$('li').hover(function(){
img.attr('src', $(this).data('link'));
});
});
Just add a css class to fadein/out
Upvotes: 2