Javascript incapable of getting element's max-height via element.style.maxHeight

Posted by Zane on Stack Overflow See other posts from Stack Overflow or by Zane
Published on 2010-03-28T02:55:07Z Indexed on 2010/03/28 3:03 UTC
Read the original article Hit count: 467

Filed under:
|
|

I am making a simple accordion menu in javascript. I'd like to be able to set the compact and expanded heights for the elements via the css max-height and min-height values. For some reason, when I try to retrieve the min-height and max-height of the elements in javascript for animation purposes, I get an empty string rather than, for instance, "500px" like it should. The max-height value is set in css, e.g. #id { min-height: 40px; max-height: 500px; } is all set up, but when I put a debugging mechanism in my javascript such as alert( item.style.minHeight ); it pops up an empty alert box. This happens in Firefox 3.6.2 and IE 8. Does anybody know why javascript refuses to be able to get an element's minHeight and maxHeight?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about css