JSFiddle - React, Tailwind, and code Playground
document 和 document.body 都绑定了 error 事件 但只有 document 被触发了这个事件
by danheberden
HTML
<a id="someElem">test</a>
JavaScript
$(function(){
$( document ).bind( 'error', function( evt ){
console.log( 'Catched event by document', evt.namespace, evt );
});
$( 'body' ).bind( 'error', function( evt ){
console.log( 'Catched event by body', evt.namespace, evt );
});
console.log( "Trigger error.custom" );
$( '#someElem' ).trigger( 'error.custom' );
console.log( "Trigger error" );
$( '#someElem' ).trigger( 'error' );
});