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