js onmouseover与onmouseout用法

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Keywords" content="关键字,关键词">
<meta name="Description" content="描述和简介">
<title>Title</title>
<style type="text/css">
*{margin:0;padding:0;}
body,ul,li,ol,dl,dd,p,h1,h2,h3,h4,h5,h6{ margin:0;}
a{text-decoration:none;}
img{border:none;}
ol,ul{list-style:none;}
#box1{height:200px;width:200px;background:pink;}
#box2{height:200px;width:200px;background:yellow;}
</style>
</head>
<body>
<div id="box1"></div>
<div id="box2"></div>
<script>
var xiaochui=document.getElementById("box2");
  var dachui=document.getElementById("box1");
dachui.onmouseover=function(){
this.innerHTML="我被碰了一下";
xiaochui.innerHTML="box1正在被碰"
};
dachui.onmouseout=function(){
this.innerHTML="我们都没被碰";
xiaochui.innerHTML="我们都没被碰"
};
xiaochui.onmouseover=function(){
this.innerHTML="我正在被碰";
dachui.innerHTML="box2正在被碰"
};
xiaochui.onmouseout=function(){
this.innerHTML="我们都没被碰";
dachui.innerHTML="我们都没被碰"
}





</script>
</body>
</html>
posted @ 2017-12-07 14:04  HACKER_LGJ  阅读(754)  评论(0编辑  收藏  举报