How to trigger event in JavaScript?

JavascriptWeb DevelopmentFront End Technology

The trigger() method triggers the specified event and the default behaviour of an event (like form submission) for the selected elements.

For example: 

$( "#foo" ).on( "click", function() {
  alert( $( this ).text() );
});
$( "#foo" ).trigger( "click" );
raja
Published on 22-Apr-2018 19:08:28
Advertisements