Thursday, June 27, 2013

jQuery event for images loaded

http://api.jquery.com/load-event/
This method is a shortcut for .on('load', handler).
The load event is sent to an element when it and all sub-elements have been completely loaded. This event can be sent to any element associated with a URL: images, scripts, frames, iframes, and the window object.
For example, consider a page with a simple image:

<img src="image1.png" alt="Image Alt Tag" id="image1" />

$('#image1')
 .load(function(){
  $('#result1').text('Image is loaded!'); 
 })
 .error(function(){
  $('#result1').text('Image is not loaded!');
 });






No comments:

Post a Comment