jQuery error() Event

Last Updated Jul 21, 2015, 12:00:06 PM

jQuery error() Event

jQuery error() event is used to bind event handler to an “error” in javascript event.


Basically jQuery .error() method will be called when an element is not loaded properly such as images, vidoes etc... In such cases, the browser will send an error message back to the HTML document.

Note: The event handler must be attached before the browser fires the error event, which is why the example sets the src attribute after attaching the handler in the below example. Also, the error event may not be correctly fired when the page was served locally; error relies on HTTP status codes will not be triggered if the URL uses the file protocol.


The above jQuery error() example will disply an error message if the image is not loading....

jQuery error() event method

Try It Now

Other Advanced jQuery Events you might want to learn

jQuery Complete Events Reference

jQuery Events

jQuery Document Events

jQuery Keyboard Events

jQuery Mouse Events

Sources and Credits

The content and methods in the tutorial has been referred and updated with jQuery API and The jQuery Foundation

Last Updated Jul 21, 2015, 12:00:06 PM