js trigger click
snippet in javascript

jquery trigger

user5898

$( "#foo" ).on( "click", function() {
  alert( $( this ).text() );
});
$( "#foo" ).trigger( "click" );

$( "#foo" ).on( "custom", function( event, param1, param2 ) {
  alert( param1 + "\n" + param2 );
});
$( "#foo").trigger( "custom", [ "Custom", "Event" ] );

js trigger click

user869

var element = document.getElementById('element');
element.click();

js trigger click

user2616

<a href="#" target="_blank" onclick="javascript:Test("Test");">MSDN</a>

js trigger click

user832

// On mouse-over, execute myFunction
function myFunction() {
  document.getElementById("myCheck").click();
}

js trigger click

user9848

const body = document.body;

body.addEventListener('click', e => {
  console.log('clicked body');
});

console.log('Using click()');
body.click();

console.log('Using dispatchEvent');
body.dispatchEvent(new Event('click'));

js trigger click

user1846

<form>
  <input type="checkbox" id="myCheck" onmouseover="myFunction()" onclick="alert('click event occurred')">
</form>