I defined the height property of an element using CSS. If the computed height is different from the defined height, then $(element).css('height') returns the computed height, not the height that I defined in CSS. I thought that css()
returns the height defined in CSS.
Here's a fiddle to show what I mean: http://jsfiddle.net/D9rQR/
I expected css()
to return 100px
, but it's returning 20px
. I'm using Chrome.
How do get the defined height (100px
in the fiddle) using JQuery/Javascript?
Edit: In the example, I set a max-height
to emulate what happens in browsers that don't support height
for select
s. I'm using the following to check if the browser computes the height properly:
if($('select').outerHeight()<parseInt($('select').css('height'))){
// browser doesn't support "height" for "select"s
}
However, this doesn't work because $('select').css('height')
always returns the computed height.