<!DOCTYPE html>
<html>
<body>
<h1>The Document Object</h1>
<h2>The createEvent() Method</h2>
<p>The createEvent() method allows you to simulate events.</p>
<p>"myDiv" will get a new star every time you mouse over it:</p>
<div id="myDiv"
style="padding:50px;background-color:yellow;"
onmouseover="this.innerHTML += '*';">*</div>
<p><button onclick="myFunction(event)">Simulate Mouse Over</button></p>
<script>
function myFunction(event) {
const ev = document.createEvent("MouseEvent");
ev.initMouseEvent("mouseover", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
document.getElementById("myDiv").dispatchEvent(ev);
}
</script>
</body>
</html>