[JavaScript] js通过onmousemove和onmouseout获取鼠标的坐标 →→→→→进入此内容的聊天室

来自 , 2019-03-01, 写在 JavaScript, 查看 108 次.
URL http://www.code666.cn/view/ffa9b486
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. function myFunction(e)
  6. {
  7. x=e.clientX;
  8. y=e.clientY;
  9. coor="Coordinates: (" + x + "," + y + ")";
  10. document.getElementById("demo").innerHTML=coor
  11. }
  12.  
  13. function clearCoor()
  14. {
  15. document.getElementById("demo").innerHTML="";
  16. }
  17. </script>
  18. </head>
  19. <body style="margin:0px;">
  20.  
  21. <div id="coordiv" style="width:199px;height:99px;border:1px solid" onmousemove="myFunction(event)" onmouseout="clearCoor()"></div>
  22.  
  23. <p>Mouse over the rectangle above, and get the coordinates of your mouse pointer.</p>
  24.  
  25. <p id="demo"></p>
  26.  
  27. </body>
  28. </html>
  29.  
  30. //javascript/7967

回复 "js通过onmousemove和onmouseout获取鼠标的坐标"

这儿你可以回复上面这条便签

captcha