如何在 JavaScript 中觸發事件?
trigger() 方法針對所選元素觸發指定的事件以及事件的預設行為(如提交表單)。
例如:
$( "#foo" ).on( "click", function() { alert( $( this ).text() ); }); $( "#foo" ).trigger( "click" );
廣告
trigger() 方法針對所選元素觸發指定的事件以及事件的預設行為(如提交表單)。
例如:
$( "#foo" ).on( "click", function() { alert( $( this ).text() ); }); $( "#foo" ).trigger( "click" );