$("#right").mouseenter(function () {});$("#right").mouseleave(function () {});
//我想在执行mouseenter的时候把mouseleave给禁用掉,因为在FF浏览器里 mouseenter和mouseleave几乎是同时执行的
解决方案 »
- 为何显示一个绝对定位的Div,在ie中能达成,在FireFox中却总不好用??
- script 中写的php代码为什么报错???
- 这是哪块的知识
- <script type="text/javascript" src="myscripts.js"></script>的问题
- 【难】求一个排列组合算法吧,这个应该是算法吧
- 这段代码运行不了,请帮忙看看
- onkeyup 和 onblur 不能一起使用?
- 孟子 E 章,麻烦你解释一下!谢谢,在线等!
- 如何实现两个select间的互动
- 在带有form表单提交的页面中,refresh页面时老是弹出,"不重新发送信息,则无法刷新网页",请问怎样才能在不再发送信息的情况下,刷新页面呢?
- JS可以关闭本地程序吗?
- 请问这种源码里面的单词变色时如何实现的呢?(有图)
行不!
mouseenter 用 mouseover 事件代替, mouseleave 用 mouseout 或 blur 事件代替 看看可以不?
鼠标离开的时候 还是需要触发mouseleave事件
嗯 我在FF中测试 是这样的 IE8 和 chrome 都是没问题的
<div id="book" style="width: 396px; height: 495px;">
<div id="right" style="width: 398px;
height: 494px; float: left; background: url(/images/1.jpg) no-repeat top left;
cursor: pointer;">
</div>
</div>var i = 1;
$("#right").mouseover(function (e) {
alert(e.type);
i++;
if (i > 2) {
i = 1;
return;
}
var roll = $("<div/>", {
css: { position: "absolute",
border: "solid 1px #999",
left: "398px",
top: "8px",
height: "494px",
width: "8px",
background: "#fff url(/images/eCX.png) repeat-y -200px 0px"
}
}).appendTo($("#book").parent());
$(roll).animate({
left: "10px",
width: "398px",
"background-position": "272px 0px"
}, 1000, function () {
$("#right").css({ "background": "url(/images/" + i + ".jpg)" });
$(roll).fadeOut(300, function () {
$(roll).remove();
})
});
});
var j = 2;
var a = 1; $("#right").mouseleave(function (e) {
alert(e.type);
j--;
if (j < 1) {
j = 2;
//return;
}
var roll = $("<div/>", {
css: { position: "absolute",
border: "solid 1px #999",
left: "8px",
top: "8px",
height: "494px",
width: "8px",
background: "#fff url(/images/eCX.png) repeat-y 200px 0px"
}
}).appendTo($("#book").parent());
$(roll).animate({
left: "8px",
width: "398px",
"background-position": "272px 0px"
}, 1000, function () {
$("#right").css({ "background": "url(/images/" + j + ".jpg)" });
$(roll).fadeOut(300, function () {
$(roll).remove();
})
});
});
// 可以在火狐中测试下效果,在images文件夹中有1.jpg,2.jpg 两张图片
这样子的话 mouseenter事件就不执行了
$("#right").mouseenter(function (event) {event.PreventDefault();});
这样子的话 mouseenter事件失效了
jquery中有这个函数的。
1.4应该是有的。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>mouseerter与mouseover区别(IE下测试)</title>
</head>
<body>
<div id="result" style="position:absolute;right:100px;top:5px;width:250px;height:400px;border:2px solid gray;overflow:auto;">
</div>
<h3>1,鼠标在div[id=parent1]内部移动时也会触发mouseover事件</h3>
<div id="parent1" style="width:400px;border:1px solid gray;padding:5px;">
<div id="child11" style="width:100px;height:100px;background:gold;float:left;">Child11</div>
<div id="child12" style="width:100px;height:100px;background:gold;float:right;">Child12</div>
<div style="clear:both;"></div>
</div>
<h3>2,鼠标在div[id=parent2]内部移动时也不会触发mouseenter事件</h3>
<div id="parent2" style="width:400px;border:1px solid gray;padding:5px;">
<div id="child21" style="width:100px;height:100px;background:gold;float:left;">Child21</div>
<div id="child22" style="width:100px;height:100px;background:gold;float:right;">Child22</div>
<div style="clear:both;"></div>
</div> <script type="text/javascript">
function on(el,type,fn){
el.addEventListener ? el.addEventListener(type, fn, false) : el.attachEvent('on' + type, fn);
}
function $(id){
return document.getElementById(id);
}
var p1 = $('parent1'),
p2 = $('parent2');
function fn(e){
var d = document.createElement('div');
d.innerHTML = e.type;
$('result').appendChild(d);
}
on(p1,'mouseover',fn);
on(p2,'mouseenter',fn);
</script>
<body>
</html>