Search code examples
jqueryhtmlimageimagemap

Why does .hover() not work on mapped images, but .mouseover() does?


Recently was working with image maps and trying to do something on hover of an image map. Naturally I tried .hover() first, but that didn't work and so when I tried .mouseover() that worked.

My question is, why does one work and not the other?

/*This function works*/
$(document).on('mouseover', '#some-map', function(){
    console.log('I am hovering with mouseover()');
}).on('mouseout', function(){
    console.log('I am no longer hovering with mouseover()');
});

/*This function does not work*/
$(document).on('hover', '#some-map', function(){
    console.log('This is from hover()');
}, function(){
    consoel.log('Out from hover()');
});

Solution

  • there ar no on('hover' ... method in jquery you can write it like this

    $('#some-map').hover(function(){
       alert('This is from hover()');
    }, function(){
       alert('Out from hover()');
    });