jQuery error: Main Tips
- The jQuery
.error()
method was used to trigger anerror
event. - It also attached a listener to the
error
event for jQuery error handling. - This method was removed in the version 3.0 of jQuery.
Triggering jQuery Errors
The .error()
function triggered an error
event, or attached a function to run when that event happened. In the example below, see how it displayed jQuery error messages:
Example
$("img").error(() => {
alert("Error: image could not be loaded!");
});
This was the syntax to trigger jQuery errors:
$("selector").error();
Attaching a listener for jQuery error handling looked like this:
$("selector").error(function);
Note: the jQuery .error() method was deprecated in version 1.8 and removed in 3.0.