I created a responsive web page in which I am trying to find the height of an element using the .outerHeight()
method in jQuery like so:
(Just an example; not really how I am using it.)
jQuery(document).ready(function($){
// Identify height of div#main
var element_h = $('.home #main').outerHeight(true);
// Apply same height to div#primary
$('.home #primary').attr('style', 'height:'+element_h+'px;');
});
The problem is that the calculated height is smaller than actual height of the element when the web page is resized (and of course, reloaded).
Considering that the web page is responsive, the element's height grows when the browser is resized. jQuery's .outerHeight()
and .height()
methods seem to calculate height properly until the scrollbar appears -- even if the entire element is still in view.
Any idea why this is happening? What could I possibly be doing wrong?