I have a table in HTML code.
I need to get height of that table using JavaScript, so
alert(document.getElementById('myTable').clientHeight);
开发者_如何学Go
returns a correct value in IE, but always returns 0 in FF.
How can I get the height of the table in Firefox?
Thanks!
MDC says:
clientHeight
is a non-standard, HTML-specific property introduced in the Internet Explorer object model.
In Firefox, the offsetHeight
property contains the current pixel height of an element, so you can use something like:
var theHeight = element.clientHeight || element.offsetHeight;
Did you tried offsetHeight? See http://www.quirksmode.org/dom/w3c_cssom.html
clientHeight works in my Firefox: http://jsfiddle.net/sZ9eg/
Maybe comeone can correct me here, but if you want to get the height of a specific element then why not just use
EDIT: this only works if the element has inline styles and a defined height
document.getElementById('myReputation').style.height;
精彩评论