I’m trying to highlight image map areas with jquery hover(),
I have highlighting divs which are absolutely positioned over the areas, I’m trying to display the div on hover but the problem is when the mouse is hovering over a particular area the highlighting happens but disappears quickly even-though the mouse is still hovering the area,
any idea what I’m doing wrong,
<div class="highlight" id="first_area_highlight"></div>
<div class="highlight" id="second_area_highlight"></div>
<map name="worksMap" id="worksMap" class="map-areas">
<area id="first_area" shape="poly" coords="80,64,176,46,186,95" />
<area id="second_area" shape="rect" coords="196,107,272,222" />
.....
</map>
$(function() {
$('.highlight').hide();
var id;
$('area').hover(function() {
id = $(this).attr('id');
highlight(id);
},function() {
unHighlight(id);
});
function highlight(id) {
$('#' + id + '_highlight').show('slow');
}
function unHighlight(id) {
$('#' + id + '_highlight').hide('slow');
}
});
the
.highlightdivs overlap yourareas, when hovering over an area, the highlight is shown, but it disappears, because thearealoses hover.What you can do, is to show
.highlighton area.mouseenter and hide.highlighton highlight.mouseleave.Here’s the idea: