mouseover与mouseout的问题,HELP

qfljm 2007-11-09 11:54:23
...全文
130 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
shagoo 2007-11-09
  • 打赏
  • 举报
回复
这是由于 mouseXXX 方法的冒泡原则引起的,给你一个思路:


var obj = null;
if (window.event) {
if (sign) {
obj = event.fromElement;
} else {
obj = event.toElement;
}
} else {
obj = e.relatedTarget;
}
while (obj!=null && obj.id!='divA_ID') { // ID of the divA
obj = obj.parentNode;
}
if (obj==null) {
// Add Your Code Here
...
}


这样子就可以在 DivA 里操作 DivB 的时候不触发 A 的 mouseXXX 事件了
nicholsky 2007-11-09
  • 打赏
  • 举报
回复
用event判断。
function onmouseout函数(event){
var o = event.target || window.event.srcElement;
if(o.id="B元素ID"){ return }
.......你原来的onmouseout函数
}
qfljm 2007-11-09
  • 打赏
  • 举报
回复
qfljm 2007-11-09
  • 打赏
  • 举报
回复
for_cyan 2007-11-09
  • 打赏
  • 举报
回复
I can't see the pic
qfljm 2007-11-09
  • 打赏
  • 举报
回复
有问题,B闪的厉害
glvicky 2007-11-09
  • 打赏
  • 举报
回复
貌似没问题吧?!
qfljm 2007-11-09
  • 打赏
  • 举报
回复

<html><head><meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css"><!--
a, a:link{text-decoration: none; color:#000000; font-size:9pt;} a:visited{text-decoration: none; color:#000000;} a:hover{text-decoration: underline; color:red;}
body, td, p, li, div, select{font-size:9pt; font-family:"宋体";}
--></style>
<script language="javascript" type="text/JavaScript">
function getOffset(el,isLeft){var retValue=0;while(el!=null){retValue += el['offset'+(isLeft?'Left':'Top')];el=el.offsetParent;}return retValue;};
var oN=null;
function ove(o)
{
var p=0, b=document.getElementById("tB");
if(o!=b)
{
p=1;
oN=o;
}
b.style.display='block';
b.style.top=getOffset(o,false)+p;
b.style.left=getOffset(o,true)+(o.offsetWidth-b.offsetWidth)-p;
b=null;
}
function out(o)
{
var b=document.getElementById("tB");
b.style.display='none';
b=null;
}
function cli(o)
{
var s='你在 '+oN.id+' 区点击了B';
document.getElementById('TX').value=s;
}
</script>
</head>

<body>
<input type="text" id="TX" />
<br /><br /><br />
<div id="tA" onmouseover="ove(this);" onmouseout="out(this);" style="width:100px;height:80px;border:1px blue solid;text-align:center;line-height:80px;">A</div>
<br /><br /><br />
<div id="tC" onmouseover="ove(this);" onmouseout="out(this);" style="width:100px;height:80px;border:1px blue solid;text-align:center;line-height:80px;">C</div>
<br /><br /><br />
<div id="tB" onmouseover="ove(this);" onmouseout="out(this);" onclick="cli(this)" style="position:absolute;z-index:100;width:30px;height:20px;border:1px red solid;text-align:center;background:#FF9966;display:none;">B</div>
</body>
</html>
glvicky 2007-11-09
  • 打赏
  • 举报
回复
MARK~
nicholsky 2007-11-09
  • 打赏
  • 举报
回复
5楼的方法第一次见,学习下。。。

楼主的问题本来就很简单嘛,不管浮动不浮动,用event就可以判断了,帖代码出来改给你看。
qfljm 2007-11-09
  • 打赏
  • 举报
回复
B是浮动对像,和A没有parentNode关系

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧