gpt4 book ai didi

jquery - mouseenter 和 mouseout 的结果更稳定?

转载 作者:太空宇宙 更新时间:2023-11-04 03:33:27 26 4
gpt4 key购买 nike

所以我想要一个很酷的功能,使用漂亮的颜色动画工具更改焦点内容区域的标题。好吧,它的动画效果很好......但它认为当鼠标仍在目标周围时你会立即鼠标移出。有谁知道如何使它稳定?我正在考虑捕捉鼠标,如果它在“区域”内,就捕捉鼠标,但我不知道这样是否更好?

        // Content Hovers

$('.large-box > *').each(function(){

$(this).mouseenter(function(){
$(this).find('.column-header').animate({ 'backgroundColor': '#3e84d2' }, 'slow');
});
$(this).mouseout(function(){
$(this).find('.column-header').animate({ 'backgroundColor': '#455c79' }, 'slow');
});

});

解决方案:解决方案是使用 mouseleave() 而不是 mouseout()

最佳答案

使用 mouseleave() 而不是 mouseout(),因为 mouseout() 也会触发子元素,应该与 mouseover() 一起使用而不是 mouseenter()。

示例:http://api.jquery.com/mouseenter/

关于jquery - mouseenter 和 mouseout 的结果更稳定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25964416/

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