pageX鼠标事件在JavaScript中的作用是什么?
触发鼠标事件时,pageX鼠标事件属性用于获取鼠标指针的水平坐标。坐标是相对于屏幕的。
示例
您可以尝试运行以下代码,以了解如何在JavaScript中实现pageX Mouse事件。
<!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>热门推荐
2 成都训练狗狗
3 怎么训练小狗狗
4 训练狗狗软件
5 如何训练狗狗拉屎
9 狗狗负重训练
10 狗狗多大可以训练大小便
11 怎么训练狗狗萨摩耶
12 狗狗训练书
13 鞍山狗狗训练
14 训练狗狗用品
15 怎样才能训练狗狗听话
16 狗狗如何训练大小便
17 怎样训练狗狗睡狗窝
18 训练狗狗工具