jQuery 效果加载太快,效果相反
我有一个元素,当鼠标悬停在上面时,它会上下滑动。但是,如果用户在页面加载时碰巧将光标放在元素上,有时会反转操作,向下和向上。这对访问者来说尤其困难,因为当他们尝试单击该元素时,该元素会不断消失。
代码片段如下所示:
$j('#gallery_holder').hover(function() {
$j('.gallery_spacer').slideToggle();
});
I have an element that, when hovered over, slides up and down. However, if the user happens to have their cursor over the element as the page loads, it sometimes reverses the action, going down and up. This makes it especially difficult for the visitor because the element is constantly disappearing on them when they try to click it.
This is what the snippet of code looks like:
$j('#gallery_holder').hover(function() {
$j('.gallery_spacer').slideToggle();
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将您的代码包装在以下内容中;
try wrapping the code you have in the following;
之前有一个答案(不知道它去了哪里)建议我使用 mouseenter() 而不是悬停()。这似乎对我有用。自从使用它以来,到目前为止我还没有能够重复这个问题。这就是我最终的结果:
所有这些都放在:
There was an answer here previously (don't know where it went) that suggested I use mouseenter() instead of hover(). This seems to be working for me. Since using it, I haven't been able to duplicate the problem so far. Here's what I ended up going with:
All this is placed within: