[jQuery] Can't get image's dimension under a hidden object

2009-11-19 Thread David .Wu
1. img src=xxx id=img1 style=display: none; / $(window).load(function() { alert($('#img1').width()); }); 2. div style=display: none; img src=xxx id=img2 style=display: none; / /div $(window).load(function() { alert($('#img2').width()); }); case 1 can get the dimension,

Re: [jQuery] Can't get image's dimension under a hidden object

2009-11-19 Thread Michael Geary
I don't think even case 1 will work in all browsers. Some browsers won't bother loading the image if it has display:none. But they will all load it if it has visibility:hidden. Here's how I do it: jQuery.imageDimensions = function( src, callback ) { jQuery('img /') .css({

RE: [jQuery] Can't get image's dimension under a hidden object

2009-11-19 Thread Josh Nathanson
, November 19, 2009 9:39 AM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Can't get image's dimension under a hidden object I don't think even case 1 will work in all browsers. Some browsers won't bother loading the image if it has display:none. But they will all load it if it has