I have used outerHeight
and outerWidth
on many places. Now, after jQuery 1.8 was released I have met a lot of issues caused by object return instead of its size.
For example:
$('#stackoverflowdiv').Height() // returns 100 px
$('#stackoverflowdiv').outerHeight() // returns "stackoverflowdiv" div
The only thing that I have found to fix this was to use "true/false" in the function as follows but the I get the same results as the standard width()
and height()
functions:
$('#stackoverflowdiv').outerHeight(true) // returns 100 px
$('#stackoverflowdiv').outerHeight(false) // returns 100 px
Has anyone knew why this is not working any more or other way to get the height/width of element + its margins.
EDIT: I started to believe that this is caused because I am selecting elements in iframe using contents()
function. I will try to make a demo.
This is actually a known jQuery bug that you can read about here.
I'm experiencing it with no parameter and the fix is setting the parameter (even though there's a default {false}), but I was able to break Barlas' fiddle by replacing the true parameter with 1 and false with 0. So don't do that if you are.
Do this:
alert(jQuery(this).outerHeight(false));
Don't do this:
alert(jQuery(this).outerHeight());
alert(jQuery(this).outerHeight(0));