.error()

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.
Home »
  Javascript Tutorial »
    jQuery Reference »
      Event
Javascript Tutorial 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()