nhuyvan1106 Posted May 24, 2014 Share Posted May 24, 2014 <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 More sharing options...
MrFish Posted May 24, 2014 Share Posted May 24, 2014 For clientHeight it really depends on your bowser. What browser are you using? Link to comment Share on other sites More sharing options...
nhuyvan1106 Posted May 24, 2014 Author Share Posted May 24, 2014 Im using chrome Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now