1const body = document.body;
2
3body.addEventListener('click', e => {
4 console.log('clicked body');
5});
6
7console.log('Using click()');
8body.click();
9
10console.log('Using dispatchEvent');
11body.dispatchEvent(new Event('click'));
1<form>
2 <input type="checkbox" id="myCheck" onmouseover="myFunction()" onclick="alert('click event occurred')">
3</form>