onmouseover/onmouseout的小意外
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了onmouseover/onmouseout的小意外相关的知识,希望对你有一定的参考价值。
div的onmouseover/onmouseout事件
div包含的子元素会引发div的onmouseover/onmouseout事件
以前好像见过有解决办法,忘了
具体代码
<!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>
<style type="text/css">
<!--
#apDiv1
position:absolute;
left:84px;
top:62px;
width:326px;
height:128px;
z-index:1;
background-color: #F00;
#apDiv2
position:absolute;
left:22px;
top:19px;
width:292px;
height:57px;
z-index:2;
background-color: #0F0;
text-align: center;
vertical-align: middle;
#apDiv3
position:absolute;
left:427px;
top:70px;
width:278px;
height:120px;
z-index:3;
background-color: #999;
.hah
font-size: 36px;
font-weight: bolder;
color: #000;
-->
</style>
<script type="text/javascript">
function a()
document.getElementById("apDiv3").innerHTML+="鼠标放上<br />";
function b()
document.getElementById("apDiv3").innerHTML+="鼠标离开<br />";
</script>
</head>
<body>
<div id="apDiv1" onmouseover="a()" onmouseout="b()">
<div id="apDiv2">为什么鼠标放到这个层会引发上红层的onmouseout事件
</div>
</div>
<div id="apDiv3"></div>
</body>
</html>
1楼所答非所问,
蛋痒
function showbg(i)
document.getElementById("tbl").style.background="url("+i+".gif)";
function hidebg()
document.getElementById("tbl").style.background="";
</script>
<table id=tbl>
<tr>
<td height=50 onmouseover="showbg(1)" onmouseout="hidebg()">11111111111111111111</td>
</tr>
<tr>
<td height=50 onmouseover="showbg(2)" onmouseout="hidebg()">22222222222222222222</td>
</tr>
<tr>
<td height=50 onmouseover="showbg(3)" onmouseout="hidebg()">33333333333333333333</td>
</tr>
<tr>
<td height=50 onmouseover="showbg(4)" onmouseout="hidebg()">44444444444444444444</td>
</tr>
</table>
以上是关于onmouseover/onmouseout的小意外的主要内容,如果未能解决你的问题,请参考以下文章