Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery height after scripts load

Tags:

jquery

I have this situation where I have a bunch of divs that get populated mostly from templates. My data comes from many sources but I am only having trouble with the div (div3) that has data coming from a script. I am trying to get the height for this div but it seems that theJQuery .height() and the .css('height') get the values after the site has rendered but NOT after the script data has returned, therefore I am getting a height of 0 even though there is data coming to populate my div. The data comes from an external source so I have no control over it. Here is what the code looks like:

<div class="div1">
    ...some code
    <div class="div2">data comes from DB</div>
    ...some code
    <div class="div3">data comes from script</div>
</div>
<div class="div4">
    ..some code
</div>

Any ideas how to get the height for div3? Thanks in advance.

like image 388
Pancho Carpio Avatar asked Jul 09 '26 18:07

Pancho Carpio


1 Answers

Have a look at this fiddle scenario

Check how the height of the div3 changes.

Maybe a reason why the height stays at '0px' is that you have declared it in css for .div3 and you forget to remove it when the data comes from your script.

like image 116
ppolyzos Avatar answered Jul 15 '26 01:07

ppolyzos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!