Load event handler.
load()event is passed to an element when it and any sub-elements attached to it have been completely loaded. This event can be sent to any element associated with frames, iframes, images, scripts, URLs and the
windowobject. Whenever possible when using the
.load()method with images, it is preferable to use the jQuery
.ready()method unless you need all images to be fully loaded before executing some code. There are also some known issues when using the
.load()method with images:
.load()method doesn't work consistently across browsers.
.load()method doesn't bubble up the DOM tree correctly.
.load()method may not fire if the images in question are already stored in the cache of the browser being used.
.load()method doesn't work correctly in WebKit browsers if the image 'src' is set to the same 'src' as previously.
- There is also a jQuery Ajax method named .load() and the method that is fired depends on the set of arguments passed.
This method was deprecated in jQuery 1.8.
|Bind an event handler to the |
|An object of data to pass to the event handler.|
|A function to execute each time the event is triggered.|
.load( [eventData], handler(eventObject) ) Example
- This signature is a shortcut for
Bind an event handler to the
In the example below we show a new message under the 'div' element with the image of chicken korma in it. As soon as the image is completely loaded the
fires off the
What we are doing here is passing across the
event object to the function
addText2(event). The map we specify, in our case
gets tagged onto the
We then access these parameters in the function via
event.data.paramN and use the passed parameters for our appended data. As mentioned in the
description above the code working depends on the browser being used when the
.load() method is applied to image elements.
We will show a message here when the