JSFiddle - React, Tailwind, and code Playground
by salman
HTML
<p>If you wait 3 seconds, a click will be dispatched to the following paragraph.</p>
<p id="someID" onclick="this.style.backgroundColor='green';">Click me and I turn green</p>
JavaScript
window.setTimeout(function() {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
var fireOnThis = document.getElementById("someID");
var dispatched = fireOnThis.dispatchEvent(evt);
if (dispatched) {
alert("Event was dispatched");
} else {
alert("Event was dispatched but preventDefault() was also called");
}
}, 3000);