在JavaScript中,clientY滑鼠事件的作用是什麼?

WBOY
發布: 2023-08-19 22:33:25
轉載
621 人瀏覽過

在JavaScript中,clientY滑鼠事件的作用是什麼?

當滑鼠事件被觸發時,使用clientY滑鼠事件屬性來取得滑鼠指標的垂直座標。這是根據目前視窗的情況。

範例

您可以嘗試執行以下程式碼來了解如何在JavaScript中實作clientY滑鼠事件。

<!DOCTYPE html>
<html>
   <body>
      <p onclick = "coordsFunc(event)">Click here to get the x (horizontal) and y (vertical) coordinates (according to current window) of the mouse pointer.</p>
     
      <script>
         function coordsFunc(event) {
            var x_coord = event.clientX;
            var y_coord = event.clientY;
            var xycoords = "X coords= " + x_coord + ", Y coords = " + y_coord;
            document.write(xycoords);
         }
      </script>
   </body>
</html>
登入後複製

以上是在JavaScript中,clientY滑鼠事件的作用是什麼?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:tutorialspoint.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!