麻烦老师帮忙检查一下
<!DOCTYPE html> <html> <head> <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() { div.style.color = "red"; content.innerHTML = "内容滚动了"; //鼠标一放入DIV颜色就先变成绿色,然后滚动窗口颜色才变为红色,如何能实现鼠标移出才绿色? } div.onmousemove = function() { div.style.color = "green"; } </script> </body> </html>
6
收起
正在回答
2回答
同学你好,参考任务步骤即可 ,鼠标移动事件中设置红色,鼠标移出事件中设置绿色。
如果我的回答帮助到了你,欢迎采纳,祝学习愉快~
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星