event.isTrusted
true: events coming from real user actions (browser).
false: events generated by scripts.
<button id="elem" onclick="alert('Click!');">Autoclick</button> <script> let event = new Event("click"); elem.dispatchEvent(event); // ⭐️ script-generated event </script>
Last updated 2 years ago
Was this helpful?