鼠标移入移出双击单击事件

- 日理万妓 2021-09-18 14:44 519阅读 0赞

qq交流群: 581478349

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <!--中文-->
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. </head>
  7. <div id="xuanzhuang">效果</div>
  8. </body>
  9. <script type="text/javascript">
  10. //函数
  11. function aaa() {
  12. //鼠标移入
  13. document.getElementById("xuanzhuang").onmouseover = function() {
  14. console.log(this)
  15. document.getElementById("xuanzhuang").style.backgroundColor = "green";
  16. }
  17. //鼠标移出
  18. document.getElementById("xuanzhuang").onmouseout = function() {
  19. console.log(this)
  20. document.getElementById("xuanzhuang").style.backgroundColor = "red";
  21. }
  22. //单击
  23. document.getElementById("xuanzhuang").onclick = function() {
  24. console.log(this)
  25. document.getElementById("xuanzhuang").style.backgroundColor = "yellowgreen";
  26. }
  27. //双击
  28. document.getElementById("xuanzhuang").ondblclick = function() {
  29. console.log(this)
  30. document.getElementById("xuanzhuang").style.backgroundColor = "#ccc";
  31. }
  32. }
  33. //调用函数
  34. aaa();
  35. </script>
  36. </html>

承接web前端开发:

v:20190220203507663.png20190220203509928.png

发表评论

表情:
评论列表 (有 0 条评论,519人围观)

还没有评论,来说两句吧...

相关阅读