title: How to wait until image is loaded in jquery
body: <p>I have this example, when my form is submitted I have to load an image file and wait until the image has loaded to <code>return true</code> (in this case to submit the form)</p>
  
  <p>e.g.</p>
  
  <pre><code>$('#myform').submit(function(){
    var image=document.createElement('image')  
    var src=document.createAttribute('src')
    image.value="http://example.com/image.jpg"
    image.setAttributeNode(src);
    document.body.appendChild(image);
  })
  </code></pre>
  
  <p>Here if I <code>return true</code> the form will be submitted (the image won't load) and if <code>false</code> it won't  (the image will load but the form will not be submitted). How can I make a code that will return true after the image has loaded.</p>