Chrome 中在文本区域上执行鼠标悬停的奇怪行为
我有一个奇怪的问题,我无法解决。它仅存在于 Chrome 中。我使用的库是 Prototype 1.6。
基本上,我将两个元素包装到一个容器元素中。两个子元素中的第一个是可见的,第二个是隐藏的。在隐藏元素内我有一个 textarea 元素。当我将鼠标悬停在容器元素上时,第一个子元素应该隐藏,第二个子元素应该显示出来。当我鼠标移出时,行为应该相反。您可以在这里看到它以及错误:)
由于某种原因,在 Chrome 中,当我将鼠标悬停在文本区域上时,元素开始闪烁,因为它们不断地自行打开和关闭。有谁知道导致这种行为的原因以及我该如何规避它?
谢谢你! 卢卡
I have a strange problem I can't wrap my head against. It is present only in Chrome. The library I'm using is Prototype 1.6.
Basically, I have two elements wrapped into a container element. First of the two children elements is visible, the second one is hidden. Inside the hidden element I have a textarea element. When I mousover the container element, the first child should hide, second one should show itself. When I mouseout, the behavior should be opposite. You can see it here, along with the bug :)
For some reason, in Chrome when I mouseover the textarea, the elements start blinking because they constantly turn themselves on and off. Does anyone have any idea what causes this behavior and how can I circumvent it?
Thank you!
Luka
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我得到的最接近的是将事件添加到鼠标移出的回调函数中,并确保它来自您想要的元素。这看起来有点 hackish,但也许这是 Chrome 中的一个错误。我也看到了,但是wong2似乎没有看到。
查看我的修订版,初始鼠标悬停时仍然有轻微的口吃。
http://jsfiddle.net/gmM9m/10/
The closest I've gotten is adding the event to the callback function for the mouseout and making sure that it's coming from the element you want. It seems kind of hackish, but perhaps it's a bug in Chrome. I'm seeing it as well, but wong2 does not seem to be seeing it.
See my revision, still a slight stutter on initial mouseover.
http://jsfiddle.net/gmM9m/10/
我刚刚遇到类似的问题并使用 jquery“mouseenter”和“mouseleave”事件解决了它
请参阅 http://api.jquery.com/mouseenter/
I just run into similar problem and solved it with using jquery "mouseenter" and "mouseleave" event
see http://api.jquery.com/mouseenter/
这对我有用。(我不熟悉 JQuery 的
observe
方法,所以我使用 JavaScript 的addEventListener
代替)重点是
stopPropagation
。在此处运行:http://jsfiddle.net/RDXzR/This works for me.(I'm not familar with JQuery's
observe
method, so I use JavaScript'saddEventListener
instead)The point is
stopPropagation
. Run it here: http://jsfiddle.net/RDXzR/