마우스 이벤트가 트리거되면 clientY 마우스 이벤트 속성을 사용하여 마우스 포인터의 수직 좌표를 가져옵니다. 이것은 현재 창에 따른 것입니다.
예시
다음 코드를 실행하여 clientY를 구현하는 방법을 배울 수 있습니다. JavaScript의 마우스 이벤트.
<!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>