Jquery mouseover / mouseleave
Jquery mouseover / mouseleave
我不确定到底要搜索什么,但这是我的问题。
<script>
function Gbox () {
var hide = document.getElementById('g-box').style.display = "none";
}
Gbox();
$("#g-plus").mouseover(function () {
$("#g-box").show(400);
});
$("#g-plus").mouseleave(function () {
$("#g-box").hide(400);
});
</script>
说Jquery工作没有问题。
唯一的问题是,如果我在#g-plus
上快速悬停2次,Jquery会像在show,hide,show,hide
中一样运行它4次,当它发生时,它看起来很迟钝
我怎样才能避免这个问题?
$("#g-plus").hover(function () {
$("#g-box").show(400);
},function () {
$("#g-box").hide(400);
});
你需要的是。stop()来停止之前的动画
function Gbox() {
$("#g-box").hide();
}
Gbox();
$("#g-plus").hover(function () {
$("#g-box").stop().show(400);
}, function () {
$("#g-box").stop().hide(400);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button id="g-plus">g-plus</button>
<div id="g-box">g-box</div>
注意:你可以使用。hover()作为注册mouseenter和mouseleave处理程序的快捷方式
相关文章:
- 音频控件在mouseover上显示,在mouseout上淡出
- Gridview ImageButton更改mouseover和mouseout上的图像
- mouseOver上的隐藏图像问题
- Javascript将aruggments传递给mouseover函数
- mouseover和mouseleave文本颜色更改在指令链接中不起作用
- jQuery与导航菜单上的mouseover事件冲突.
- 当DOM节点在DOM中移动时,如何阻止Firefox触发mouseleave
- 使用mouseover方法时无法保护svg的颜色
- jQuery"或“;操作员没有处理mouseleave
- 有没有办法将mouseOver上的个人文本添加到完整日历中
- 在mouseover上添加边框,在mouseout上删除边框
- IE 11未在SVG地图上启动Mouseenter或Mouseleave事件
- Mouseover和Mouseout的行为没有达到预期
- 如何降低JavaScript中Mouseover函数的资源密集度
- jquery mouseenter - mouseleave not working
- Fancybox:让它在mouseover/mouseout上工作
- 在mouseover上显示元素在mouseleave上隐藏
- Javascript(mouseover mouseleave)html元素未返回
- 如何将mouseover和mouseleave事件与jquery中的不同目标相关联
- Jquery mouseover / mouseleave