JS获取鼠标在页面中点击的坐标

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <title>Screen Coordinates Example</title>
 5     </head>
 6     <body style="width: 1440px;height: 1000px;">
 7         <div id="div"></div>
 8         <script type="text/javascript">
 9             let body = document.getElementsByTagName('body');
10             body[0].onclick = (e) => {
11                 console.log(e.screenX, e.screenY)
12             }
13         </script>
14     </body>
15 </html>

 

posted @ 2020-08-07 19:12  yw3692582  阅读(765)  评论(0编辑  收藏  举报