[jQuery] Why won't this get the image's width?
<html>
<body>
Hello folks,
This piece of code
<tt> if
(($('#theImage').length>0)) {
var
img_width = $('#theImage').width();
<x-tab> </x-tab><x-tab>
</x-tab>
$.log(img_width);
$("#sCaption").css("width",img_width);
};
</tt>follows an ajax call to bring content to an existing div...
<tt>
$.get("scripts/ajax_ramosus_client_second.asp?brm="+ej
+"&q=" + new Date().getTime(),
function(responseText){
$("#wrapper").html(responseText);
</tt>I don't understand why the width is always being reported as
0.
The relevant portion of the HTML being returned is...
<pre><img src="images/ramosus/dicentra/dicentra1.jpg"
id="theImage" class="pad5"
alt=""><div id="sCaption" style="width:
0pt;">
Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Duis in ipsum. Donec faucibus sodales
lacus?</div>
</pre>Any ideas?
Is it, perhaps, that if the image hasn't loaded before the code is
processed, then the width of theImage will be 0. If so, how do I
code around this issue?
Thanks,
Bruce</body>
</html>