본문 바로가기
프로그래밍/Javascript

테이블 위치값 구하기(스크립트)

by redarim 2011. 6. 17.

<table border=0 id=seol>

<tr>

<td>

zzzz

</td>

</tr>

</table>

<script>
var el = document.all.seol;
var rect = el.getBoundingClientRect();
/*
 var s = ""; 
 s+="body로부터 left : " + (rect.left-2) + "<br>";
 s+="body로부터 top : " + (rect.top-2) + "<br>";
 s+="table로부터 left : " + el.offsetLeft + "<br>";
 s+="table로부터 top : " + el.offsetTop + "<br>"; 
*/
intLeft = (rect.left-2);
intTop = (rect.top-2);
alert(intLeft+'|'+intTop);
document.all.Layer2.style.left = intLeft;
document.all.Layer2.style.top = intTop;
</script>