Image load error!

"); }); ``` --- "> Image load error!

"); }); ``` --- " />
Easy Tutorial
❮ Jquery Ajax Get Post Sel Parent ❯

jQuery error() Method

jQuery Event Methods

Example

If an image element encounters an error, replace it with text:

$("img").error(function(){ $("img").replaceWith("<p>Image load error!</p>"); });

Definition and Usage

When an element encounters an error (when the element fails to load correctly), the error event occurs.

The error() method triggers the error event, or specifies a function to run when an error event occurs.

Tip: This method is a shorthand for bind('error', handler).


Syntax

Trigger the error event for the selected elements:

Attach a function to the error event:

Parameter Description
function Optional. Specifies the function to run when the error event occurs.

jQuery Event Methods

❮ Jquery Ajax Get Post Sel Parent ❯