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