user2413333
user2413333

Reputation: 1405

Getting .outerheight() of div with no set css returns wrong number

I am trying to get the height of a div that has no set height in css. When I hover over it with inspect element it says it is 92px high, however when I do the following in Javascript:

jQuery(document).ready(function($) {    
    var heightSomething= jQuery('#something').outerHeight();
    console.log(heightSomething);
});

I always get "24". If I set a height in css to #something, then the console does log the correct height. Is there some sort of limitation to finding heights of divs with no set height? Thanks guys.

Upvotes: 0

Views: 2544

Answers (1)

A. Wolff
A. Wolff

Reputation: 74420

Maybe try using load handler instead: { if there are some images/ajax }

jQuery(window).load(function() {    
    var heightSomething= jQuery('#something').outerHeight();
    console.log(heightSomething);
});

Upvotes: 2

Related Questions