js trigger click on element code example

Example 1: js trigger click

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

Example 2: javascript trigger click on element

document.getElementById('myElementID').click();

Example 3: js trigger click

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

Example 4: js trigger click

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

Tags:

Misc Example