[英]Mouseenter and Mouseleave dropdown menu
I'm trying to have this dropdown menu to show the submenu when mouse is hover it and stay hover when on top of the submenu as well, but when the mouse leaves, I want it to hide it.我试图让这个下拉菜单在鼠标为 hover 时显示子菜单,并在子菜单顶部保持 hover ,但是当鼠标离开时,我希望它隐藏它。
The following link, I was only able to change the javascript to mouseenter, but I don't know how to create the mouseleave function.以下链接,我只能将javascript更改为mouseenter,但我不知道如何创建mouseleave function。
It's probably super easy for anyone who knows how to code, but I don't:(对于任何知道如何编码的人来说,这可能非常容易,但我不会:(
Here is the link: https://codepen.io/ok2ju/pen/MwyvWY这是链接: https://codepen.io/ok2ju/pen/MwyvWY
And here is the code:这是代码:
document.querySelector('.mini-photo-wrapper').addEventListener('mouseenter', function() {
document.querySelector('.menu-container').classList.toggle('active');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.