09.02.2015 Views

DOM Traversal Methods - MarkMail

DOM Traversal Methods - MarkMail

DOM Traversal Methods - MarkMail

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5<br />

.load()<br />

Binds an event handler to the load JavaScript event.<br />

.load(handler)<br />

Parameters<br />

• handler: A function to execute when the event is triggered<br />

Return Value<br />

The jQuery object, for chaining purposes.<br />

Description<br />

This handler is a shortcut for .bind('load', handler).<br />

The load event is sent to an element when it and all sub‐elements have been<br />

completely loaded. This event can be sent to any element associated with a<br />

URL—images, scripts, frames, and the body of the document itself.<br />

For example, consider the HTML:<br />

<br />

The event handler can be bound to the image:<br />

$('.target').load(function() {<br />

$(this).log('Load event was triggered.');<br />

});<br />

Now as soon as the image has been loaded, the message is displayed.<br />

In general, it is not necessary to wait for all images to be fully loaded. If code<br />

can be executed earlier, it is usually best to place it in a handler sent to the<br />

.ready() method.<br />

The AJAX module also has a method named .load(). Which one is fired<br />

depends on the set of arguments passed.<br />

[ 105 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!