error()
error()は画象が読み込みできないなどのエラーが発生した際に発火するイベントです。
jQuery 1.8で非推奨になり、onメソッドを利用してJavaScriptのerrorイベントをバインディングする方法が推奨されています。
error()はimg要素などで画象の読み込みが失敗した際に発生するイベントです。
$("<img>").error(function(){
alert("画象が読み込みできませんでした");
}).attr("src","nothing.gif");
引数としてイベントデータを引き渡すことが可能です。
$("<img>").error("ok",function(e){
alert(e.data);
}).attr("src","nothing.gif");
jQuery 1.4.3での追加/変更jQuery 1.4.3からイベントデータを引き渡すことが可能になりました。
登録日 : 2013年02月07日 最終更新日 : 2013年2月7日
同じカテゴリー(Events)のエントリー
- change()
- blur()
- unload()
- unbind()
- submit()
- select()
- scroll()
- mouseleave()
- mouseenter()
- keyup()
- keypress()
- keydown()
- focusout()
- focusin()
- focus()
- die()
- delegate()
- dblclick()
- bind()
- undelegate()
- error()
- off()
- resize()
- mouseup()
- mousemove()
- mousedown()
- mouseout()
- mouseover()
- click()
- on()
- load()
- ready()