Contents:
.on( "load" [, eventData ], handler )Returns: jQuery
Description: Bind an event handler to the "load" event.
-
version added: 1.7.on( "load" [, eventData ], handler )
load
event. For the .load()
method removed in jQuery 3.0, see .load()
.
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.
1
|
|
1
2
3
|
|
.ready()
method.
load
event when used with images
load
shortcut is to execute a function when an image (or collection of images) have completely loaded. There are several known caveats with this that should be noted. These are:
- It doesn't work consistently nor reliably cross-browser
- It doesn't fire correctly in WebKit if the image src is set to the same src as before
- It doesn't correctly bubble up the DOM tree
- Can cease to fire for images that already live in the browser's cache
.live()
and .delegate()
methods cannot be used to detect the load
event of an iframe. The load event does not correctly bubble up the parent document and the event.target isn't set by Firefox, IE9 or Chrome, which is required to do event delegation.
Examples:
Example 1
1
2
3
|
|
Example 2
1
2
3
4
5
|
|
.trigger( "load" )Returns: jQuery
Description: Trigger the "load" event on an element.
-
version added: 1.0.trigger( "load" )
-
"load"Type: stringThe string
"load"
.
-
.on( "load", ... )
.