jQuery Event - error() Method
Example
If the image does not exist, replace it with a predefined text:
$("img").error(function(){ $("img").replaceWith("Missing image!
"); });
Definition and Usage
An error event occurs when an element encounters an error (not loaded correctly).
The error() method triggers an error event or specifies a function to be executed when an error event occurs.
Tip:This is a shorthand for bind('error', handler).
Binds a function to the error event
Syntax
$(selector).error(function)
Parameter | Description |
---|---|
function | Optional. Specifies a function to be executed when an error event occurs. |