offsetParent 예제
<div id="hz"> <p><button onclick="homzzang()">클릭</button></p> <p>DIV 요소의 offsetParent : <span id="demo"></span></p> </div> <script> function homzzang() { var hz = document.getElementById("hz"); document.getElementById("demo").innerHTML = hz.offsetParent; } </script> 결과보기
<div id="hz">
<p><button onclick="homzzang()">클릭</button></p>
<p>DIV 요소의 offsetParent : <span id="demo"></span></p>
</div>
<script>
function homzzang() {
var hz = document.getElementById("hz");
document.getElementById("demo").innerHTML = hz.offsetParent;
}
</script>
결과보기
결과값: DIV 요소의 offsetParent : [object HTMLBodyElement]