老师请看下代码是否正确
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>mouse</title>
<style type="text/css">
#div{overflow:auto;width:200px;height:200px;border:2px solid gray;margin-bottom:20px;}
#content{width:200px;height:100px;border:2px solid gray;}
</style>
</head>
<body>
<div id="div">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod,tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo,consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse,cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non,proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div id="content"></div>
<script type="text/javascript">
//获取两个文本框
var div=document.getElementById("div");
var content=document.getElementById("content");
//给带滚动带文本绑定事件
div.onscroll=function(){
content.innerText="内容滚动了";
}
//绑定鼠标移动触发事件,字体变红
div.onmousemove=function(){
div.style.color="red";
}
//绑定鼠标离开触发事件,字体变绿
div.onmouseout=function(){
div.style.color="green"
}
</script>
</body>
</html>
正在回答
同学你好,代码实现的是正确的。继续加油,祝学习愉快~
相似问题
登录后可查看更多问答,登录/注册
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星