当鼠标事件被触发时,pageX鼠标事件属性用于获取鼠标指针的水平坐标。坐标是相对于屏幕的。
您可以尝试运行以下代码来了解如何实现pageX JavaScript 中的鼠标事件。
<!DOCTYPE html> <html> <body> <p onclick = "coordsFunc(event)"> Click here to get the x (horizontal) and y (vertical) coordinates of the mouse pointer. </p> <script> function coordsFunc(event) { var x_coord = event.pageX; var y_coord = event.pageY; var xycoords = "X coords= " + x_coord + ", Y coords= " + y_coord; document.write(xycoords); } </script> </body> </html>
以上就是pageX Mouse Event在JavaScript中的作用是什么?的详细内容,更多请关注php中文网其它相关文章!
已抢23149个
抢已抢117553个
抢已抢139119个
抢已抢6188个
抢已抢35154个
抢已抢7810个
抢