gpt4 book ai didi

当鼠标已经位于 onLoad 元素上方时,带有 .toggle() 的 jQuery MouseEnter 和 MouseOut 事件会反转?

转载 作者:行者123 更新时间:2023-12-01 01:20:38 25 4
gpt4 key购买 nike

我有一个下拉菜单,可以很好地使用以下代码:

$('#menu ul li').mouseenter(function(){
$(this).children(".dropdown").toggle();
}).mouseleave(function(){
$(this).children(".dropdown").toggle();
});

这正如您所期望的那样工作。问题是,如果当 $(document).ready(function() 时,鼠标已经在 $('#menu ul li')mouseenter { }) 被触发,切换会以相反的方式工作吗?

如何避免这种情况?

EG:http://screenr.com/wbd

最佳答案

您不想在 mouseenter 上执行 show() 并在 mouseleave 上执行 hide() 吗?

关于当鼠标已经位于 onLoad 元素上方时,带有 .toggle() 的 jQuery MouseEnter 和 MouseOut 事件会反转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2213155/

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