Reputation: 3587
I have a mouseover and mouseleave on an image, that will hide or show a div. All the images are in a class "imgmouse" and all the div's are in a class "tri-bottom", how can I write this jquery so the first tri-img will show and hide the first tri-bottom div and so on. So mouse over the first .imgmouse img and show div.triangle-rollover and mouseover the second .imgmouse img and show the second div.triangle-rollover??
Code:
$('.imgmouse img, .tri-col td.tri-img span').mouseover(function() {
$(".triangle-rollover").show();
});
$('.imgmouse img, .tri-col td.tri-img span').mouseleave(function() {
$(".triangle-rollover").hide();
});
this relates to this table:
<td class="tri-img"><img class="one" src="img/triangles/triangle33.png" alt="" ><span class="tri-val one">${StatsCube.parseInt(ChartData.PTS)}</span></td>
<td class="tri-img"><img class="two" src="img/triangles/triangle33.png" alt="" ><span class="tri-val two">${StatsCube.parseInt(ChartData.FGA)}</span></td>
<td class="tri-img"><img class="three" src="img/triangles/triangle33.png" alt="" ><span class="tri-val three">${StatsCube.parseInt(ChartData.TPA)}</span><span>%</span></td>
Upvotes: 0
Views: 460
Reputation: 5912
You can use the index of the image being mouseover:
$('.imgmouse img').bind('mouseover mouseout', function(e) {
var index = $('.imgmouse img').index(this),
$div = $('.tri-bottom div').eq(index);
if(e.type == 'mouseout') {
$div.hide();
} else {
$div.show();
}
});
Upvotes: 1