offsetX 예제 - 상자 안 click 시, Y좌표 표시
<style> div {border:1px solid red; height:300px;} span {font-size:30px;} </style> <div onclick="homzzang(event)"></div> <span id="hz"></span></p> <script> function homzzang(event) { var x = event.offsetX; document.getElementById("hz").innerHTML = x; } </script> 결과보기
<style>
div {border:1px solid red; height:300px;}
span {font-size:30px;}
</style>
<div onclick="homzzang(event)"></div>
<span id="hz"></span></p>
<script>
function homzzang(event) {
var x = event.offsetX;
document.getElementById("hz").innerHTML = x;
}
</script>
결과보기