I have a script which requires the height of a certain div.
The problem is the .height()
method in jQuery does not return the proper value, unless it is places inside a setTimeout
function, even with the values of 0
.
So this:
console.log("1:" + $(slides[0]).find('.slide__inner').height());
setTimeout(function(){console.log(
"2:" + $(slides[0]).find('.slide__inner').height());}
, 0);
Results in this
1: 0
2: 399 //expected value
Now I am aware of the browser multi threading thing, and that elements inside timer elements run in their own....dimensions, but I need to make this selector print the correct values without using setTimeout, or any timer functions.
Additional info:
The target div is position absolute, the function itself is meant to fire-up specifically after the inside content (and the height) is all set.
Edit
This is not a duplicate of When should I use jQuery's document.ready function? . I specifically said I dont wan't to use setTimeout....
Edit2
The mentioned afterLoad
function is a part of the Fancybox3 js plugin.
Reading from the source found here :
afterLoad : $.noop, // When the content of a slide is done loading
I am not allowed to show too much of the code due to work restrictions, but the block itself is place within a resize()
declared inside afterLoad
, which gets called by the end of the afterLoad
block