pageY 滑鼠事件在 JavaScript 中的作用是什麼?
滑鼠事件觸發後,pageY 滑鼠事件屬性將用於獲取滑鼠指標的垂直座標。座標相對於螢幕。
舉例
你可以嘗試執行以下程式碼,瞭解如何在 JavaScript 中實現pageY 滑鼠事件。
<!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>
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP