<html>
<body>
<div id="cs" style="width:300px;height:300px;background:red;">
<div style="width:100px;height:100px;background:green;"></div>
</div>
</body>
</html>
<script>
var a
a=document.getElementById('cs')
a.onmouseout=function(evt){
cancelBubble(evt);
a.style.display='none';
}
function cancelBubble(e)
{
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
};
</script>
有为什么错 大侠们快快指出。 坐等!
<body>
<div id="cs" style="width:300px;height:300px;background:red;">
<div style="width:100px;height:100px;background:green;"></div>
</div>
</body>
</html>
<script>
var a
a=document.getElementById('cs')
a.onmouseout=function(evt){
cancelBubble(evt);
a.style.display='none';
}
function cancelBubble(e)
{
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
};
</script>
有为什么错 大侠们快快指出。 坐等!
解决方案 »
- jquery 怎样实现div 的滚动条自动滚动?
- function方法中变量公用的吗?
- DIV如何实现类似框架跳转 点击左边文本链接,然后在右边DIV块里面显示
- 哪位知道怎么用javascript实现sliding bar
- scriptX打印控件是免费的吗?好像它分客户端和服务器端。scriptX的版权到底是怎样的?是免费的吗?
- 请教不用form表单,如何传递checkbox的值
- innerHTML JS如何调JS代码.
- JS代码混淆初步
- 在一个事件处理器内,怎样同时调用来自不同.js文件的方法?
- 如何监控页面上任一元素(html元素)是否完全加载成功?急求
- 这样的一个function应该怎么写,怎么写,怎么写……
- .net服务器控件 调用js(c#button与js结合问题)
{
e=e||window.event;
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
};
IE中该对象为window.event(window可省略) 而Firefox中该对象为e
<body>
<div id="cs" style="width:300px;height:300px;background:red;">
<div style="width:100px;height:100px;background:green;"></div>
</div>
</body>
</html>
<script>
var a,b,c
a=document.getElementById('cs')
a.onmouseout=function(evt){
cancelBubble(evt);
a.style.display='none';
}
function cancelBubble(e)
{
e=e||window.event;
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
};
</script>完整代码
<body>
<div id="cs" style="width:300px;height:300px;background:red;">
<div style="width:100px;height:100px;background:green;"></div>
</div>
</body>
</html>
<script>
var a,b,c
a=document.getElementById('cs')
a.onmouseout=function(event){
e=e||window.event;
cancelTheBubble(e);
a.style.display='none';
}
function cancelTheBubble(e)
{if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
};
</script>
还有就是event参数的处理,注意一下就好了
<body>
<div id="cs" style="width:300px;height:300px;background:red;">
<div style="width:100px;height:100px;background:green;"></div>
</div>
</body>
</html>
<script>
var a,b,c
a=document.getElementById('cs')
a.onmouseout=function(event){
e=event||window.event; \\这里我也改了 用 e=e||window.event; FF说e on defined
cancel(e);
a.style.display='none';
}
function cancel(e)
{
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
};
</script> 改了还是不好使
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<div id="cs" style="width:300px;height:300px;background:red;">
<div style="width:100px;height:100px;background:green;"></div><script>
var a,b,c;
a = document.getElementById('cs');
a.onmouseout = function(event) {
e = event || window.event;
cancelTheBubble(e);
a.style.display = 'none';
}
function cancelTheBubble(e)
{
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
}
</script></body>
</html>
<html>
<body>
<div id= "cs " style= "width:300px;height:300px;background:red; ">
<div style= "width:100px;height:100px;background:green; "> </div>
</div>
</body>
</html>
<script>
var a
a=document.getElementById( 'cs ')
a.onmouseout=cancel(evt);
a.style.display= 'none ';
}
function cancel(e)
{
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
};
</script>
<html>
<body>
<div id= "cs " style= "width:300px;height:300px;background:red; ">
<div style= "width:100px;height:100px;background:green; "> </div>
</div>
</body>
</html>
<script>
var a
a=document.getElementById( 'cs ')
a.onmouseout=function()
{
return false;
}
a.style.display= 'none ';
} </script> 这个更通用
你怎么总喜欢用保留字啊
if (e.type != 'mouseout' && e.type != 'mouseover') return false;
var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;
while (reltg && reltg != handler)
reltg = reltg.parentNode;
return (reltg != handler);
} onmouseover="if (isMouseLeaveOrEnter(event,this))cle()" onmouseout="if (isMouseLeaveOrEnter(event,this)) start()"
<html>
<body>
<div id= "cs " style= "width:300px;height:300px;background:red; ">
<div style= "width:100px;height:100px;background:green; "> </div>
</div>
</body>
</html>
<script>
var a
a=document.getElementById( 'cs ')
a.onmouseout=function()
{
return false;
a.style.display= 'none';
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<div id="cs" style="width:300px;height:300px;background:red;">
<div style="width:100px;height:100px;background:green;">123</div>
</div><script>
var a = document.getElementById('cs');
a.onmouseout = function () { a.style.display = 'none'; }
a.getElementsByTagName('div')[0].onmouseout = function() { cancelTheBubble(event); }function cancelTheBubble(e)
{
e = e || window.event;
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
}
</script></body>
</html>
http://www.chhua.com/web-note1109
如果是获取里面的div,并调用事件的话就不冒泡了,例如 <body>
<div style="width:300px;height:300px;background:red;">
<div id="cs" style="width:100px;height:100px;background:green;"></div>
</div>
<script>
var a,b,c;
a = document.getElementById('cs');
a.onmouseout = function(event) {
e = event || window.event;
cancelTheBubble(e);
a.style.display = 'none';
}
function cancelTheBubble(e)
{
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
}
</script></body>
</html>
但是这确实是一个 onmouseout的 非逻辑事件,
我一开始以为用冒泡可以停止,但是现在无效了 需要另想办发
我有两个思路但是具体怎么写还需要研究。
第一个就是用 小区块的 onmouseover 和 onmouseout 做抵消
第二个就是 用 小区块做向上的循环查找 看时候父级以上 区块是否有 id为 事件绑定的区块,
但是具体要如何写还要想
有时间应该用 向上循环查找ID的办法做一个 函数。