Result Size: 625 x 534
x
 
<!DOCTYPE html>
<html>
<body>
<p>此示例使用 HTML DOM 将“onmouseenter”和“onmouseleave”事件分配给 h1 元素。</p>
<h1 id="demo">鼠标悬停在我身上</h1>
<script>
document.getElementById("demo").onmouseenter = function() {mouseEnter()};
document.getElementById("demo").onmouseleave = function() {mouseLeave()};
function mouseEnter() {
  document.getElementById("demo").style.color = "red";
}
function mouseLeave() {
  document.getElementById("demo").style.color = "black";
}
</script>
</body>
</html>