Jump to content

clientHeight property


nhuyvan1106

Recommended Posts

<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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...