感谢您的支持,我会继续努力的!
打开微信扫一扫,即可进行扫码打赏哦
点我查看本站打赏源码!
Powered by RUNCODEX.COM,学的不仅是技术,更是梦想!!!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312"/>
<title>事件绑定及深入</title>
<style type="text/css">
.red{
width:100px;
height:100px;
background:red;
}
.blue{
background:blue;
#pox{
width:150px;
background:orange;
display:block;
</style>
<script type="text/javascript" src="JAVA SCRIPT"></script>
</head>
<body>
<span id="pox">
<div id="box">测试Div</div>
</span>
</body>
</html>
xxxxxxxxxx
function addEvent(obj,type,fn){
if(obj.addEventListener){
obj.addEventListener(type,fn,false);
}else if(obj.attachEvent){
obj.attachEvent('on'+type,fn);
function removeEvent(obj,type,fn){
if(obj.removeEventListener){
obj.removeEventListener(type,fn,false);
}else if(obj.detachEvent){
obj.detachEvent('on'+type,fn);
addEvent(window,'load',function(){
var box=document.getElement('box');
// addEvent(box,'mouseover',function(evt){ 得到移入box最近的那个DOM对象
// alert(evt.relatedTarget);
//});
addEvent(box,'mouseout',function(evt){ //从box移出最近的那个DOM对象
alert(evt.relatedTarget);
});
#box{
font-size:20px;
color:red;
background:#ccc;
#pox
{
color:green;
border:1px solid black;
.bbb{
font-weight:bold;