.error()

In this chapter you will learn:

  1. Syntax and Description for .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.

Next chapter...

What you will learn in the next chapter:

  1. Syntax and Description for .dblclick() event
  2. Bind double click event for paragraph
  3. How to slide up a paragraph after double clicking
Home » jQuery » Event
Event
Event attributes
event.keycode
event.clientX/clientY
pageX/pageY
Cancel event
Event target
bind
.blur()
.change()
.click()
.error()
.dblclick()
.delegate()
.die()
.focus()
.hover()
.keydown()
.keypress()
.keyup()
.live()
.load()
.mousedown()
.mouseenter()
.mouseleave()
.mousemove()
.mouseover()
.mouseout()
.mouseup()
.off()
.on()
.one()
.ready()
.resize()
.scroll()
.select()
.submit()
.toggle()
.trigger()
.triggerHandler()
.unbind()
.undelegate()
.unload()