简体   繁体   中英

jQuery 1.7.1 height() stopped working

I have used jQuery 1.6.2 so I can get <div id="drag-container"> width and height and it was working fine

But when I changed to jQuery 1.7.1 I start to have a problem with IE (9.0)

in $(document).ready() function

$("#drag-container").height() returns 0

and the web page stops it's initial rendering for a 5 seconds.

In fact page is almost fully rendered except (may be) the same <div id="drag-container">

Can this be my fault?

I'm also using HTML5 Boilerplate and Twitter Bootstrap with Less

If there are images in the #drag-container element, then you should use the $(window).load() ( as you rightly corrected in the comment ) instead of the .ready() .

That is because the ready event is fired once the DOM is ready to be manipulated ( the actual html ) while the load event is fired once all assets of the page have been loaded ( including images etc ).

So your code will be running before the images are loaded, and thus their container will not have acquired its height ( which might depend on its content - the images.. )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM