The height(); of bad manners
Hello there, to quote Alec Guiness, today i’ve found yet another jQuery inconsistency that needs to be made note of! It would seem that certain version of IE (looks like 8 and 9) along with Opera don’t officially support the jQuery height() function.
In my case I was using the function to dynamically set the css height attribute of some div’s, using jQuery to calculate the actual height:
jQuery('#outer > div').each(function () {
jQuery(this).css('height', jQuery(this).height());
});
This worked fine in firefox, chrome and safari. But in the
aforementioned odd browsers, the height was coming out as nearly double
what it should be. The solution for this was to instead use
innerHeight()
rather than height. The code then looked like this:
jQuery('#outer > div').each(function ()
jQuery(this).css('height', jQuery(this).innerHeight());
});
Bit of a weird one, but all in a days work :p