Триггер JavaScript Нажмите на элемент
document.getElementById('myElementID').click();
Friendly Hawk
document.getElementById('myElementID').click();
var element = document.getElementById('element');
element.click();
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'));
// On mouse-over, execute myFunction
function myFunction() {
document.getElementById("myCheck").click();
}
<form>
<input type="checkbox" id="myCheck" onmouseover="myFunction()" onclick="alert('click event occurred')">
</form>
<a href="#" target="_blank" onclick="javascript:Test("Test");">MSDN</a>