<html><head><script type="text/javascript"> function showPosition() { var oElement = document.all.oCell; var myDiv = document.all.myDiv; alert("The span element is at (" + oElement.offsetLeft + "," + oElement.offsetTop + ")n" + "The offset parent is " + oElement.offsetParent.tagName + " offsetHeight is " + oElement.clientHeight); } </script></head><body onload="showPosition()"><div id = "myDiv" style = "width: 100px; padding: 10px 20px; position: relative; border: 1px solid black;float: right;"> <span id="oCell">This is a small table.</span> </div></body></html>
Hi guys, I was messing around with the offsetSomething and clientHeight properties(experimenting with them actually), I noticed that clientHeight always returned "0" on that span element, when I changed to offsetHeight, it returned a value other than "0", BUT when set "style = 'display:block' " on that <span> element, clientHeight returned some value other than "0", and everytime I removed "style = 'display: block;' ", clientHeight returned "0", so clientHeight property only works on block-level elements or am I doing something wrong here? Thank you in advance guys.