jQuery width() returns 0
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/544993/official-way-to-ask-jquery-wait-for-all-images-to-load-before-executing-somethin">Official way to ask jQuery wait for all images to load before executing something</a>  </p>
</blockquote>



<p>I'm writing a jQuery plugin that handles a bunch of image animations with a simple call to the plugin function (something like <code>$("#image1").anims()</code> where <code>#image1</code> is an image), however as part of the plugin's functionality I use <code>$(this).width()</code> to get the width of the image right at the start of the function call. </p>

<p>But, since the plugin function is called in <code>$(document).ready</code>, it's trying to get the width of the image before the image has loaded, so it's always returning 0. Is there a workaround for this?</p>
