gpt4 book ai didi

jquery - 为什么 .hover() 不适用于映射图像,但 .mouseover() 可以?

转载 作者:可可西里 更新时间:2023-11-01 14:47:38 27 4
gpt4 key购买 nike

最近在处理图像映射并尝试在图像映射悬停时做一些事情。当然,我首先尝试了 .hover(),但是没有用,所以当我尝试 .mouseover() 时,它起作用了。

我的问题是,为什么一个有效而另一个无效?

/*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()');
});

最佳答案

在 jquery 中没有 on('hover' ... 方法你可以这样写

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

关于jquery - 为什么 .hover() 不适用于映射图像,但 .mouseover() 可以?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26784862/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com