老师请看下代码是否正确
<!--
(1) 当鼠标在带滚动条的文本框上滑动时,字体颜色变成红色
(2) 当鼠标移出带滚动条的文本框时,字体颜色变成绿色
(3) 当鼠标移动文本框的滚动条时,空白的文本框出现文本“内容滚动了”
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</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>
var div = document.getElementById("div");
var con = document.getElementById("content");
div.onscroll = function () {
con.innerHTML = "内容滚动了";
}
div.onmousemove = function(){
div.style.color = "red";
}
div.onmouseout = function () {
div.style.color = "green";
}
</script>
</body>
</html>
正在回答 回答被采纳积分+1
相似问题
登录后可查看更多问答,登录/注册
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星