关于div的mouseout事件触发不准的解决办法

 <!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>
<script type="text/javascript">
function test(obj, e) {
if (e.currentTarget) {
   if (e.relatedTarget != obj) {
    if (obj != e.relatedTarget.parentNode) {
     alert(1);
    }
   }
} else {
   if (e.toElement != obj) {
    if (obj != e.toElement.parentNode) {
     alert(1);
    }
   }
}
}
</script>
<div onmouseout="test(this, event)" style="width:100px;height:100px;border:1px #666 solid">
<span style="margin:5px;width:100%;height:100%;border:1px #ff0000 solid">faddsf</span>
</div>
</body>
</html>

你可能感兴趣的:(html,XHTML,function,div,border)