<form>
<input type="checkbox" id="myCheck" />
</form>HTMLElement: click() method / notebook
HTMLElement: click() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const checkbox = document.getElementById("myCheck");
// On mouse-over, execute myFunction
checkbox.addEventListener("mouseover", () => {
// Simulate a mouse click
checkbox.click();
});
checkbox.addEventListener("click", () => {
console.log("click event occurred");
});