简单教程
提交运行
代码编辑器:
<p>演示了如何向 h1 元素添加 "onmouseenter" 和 "onmouseleave" 事件</p> <h1 id="demo" onmouseenter="mouseEnter()" onmouseleave="mouseLeave()">鼠标移到我这</h1> <script> function mouseEnter() { document.getElementById("demo").style.color = "red"; } function mouseLeave() { document.getElementById("demo").style.color = "black"; } </script>
运行结果: