jQuery .error() event
Syntax and Description
.error(handler)
handler
is a function to execute when the event is triggered.
Return value is the jQuery object, for chaining purposes.
This method is a shortcut for .bind('error', handler). It binds an event handler to the error JavaScript event.
For example:
<img src="notThere.png" alt="Book" id="myImage" />
The event handler can be bound to the image.
$('#myImage').error(function() {
$.print('Error loading image.');
});
If the image cannot be loaded, the following message is displayed:
Error loading image.