- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Not able to calculate the height of the div.
Main div has a bootstrap carousel in it.
I am trying to fetch the height of the main div using jquery height() .
Sometimes it gives the correct height of the div, but sometimes i am getting wrong height.
before the carousel is loaded the height is calculated.
Calling the jquery height on document ready and on window onload.
In IE always getting the wrong height.
Care to show your code?
We can’t diagnose what we can’t see.
I could see this happening if your code runs before the carousel has fully initialized. The carousel might inject content into the page after your doc ready. It might explain why it works sometimes. But yeah, hard to say without seeing some code.
Make sure the element is in a state where height is able to be accurately calculated.
ex: hidden elements will have a height of 0 until they’re state is changed