在 HTML 中鼠标指针移过元素时如何执行脚本?
在 HTML 中,当鼠标指针移过元素时,onmouseover 属性被触发。
示例
你可以尝试运行以下代码来实现 onmouseover 属性 −
<!DOCTYPE html>
<html>
<body>
<h3 id = "myid" onmouseover = "display()">
This is demo heading.
</h3>
<p>Keep the mouse cursor on the heading to change the color.</p>
<script>
function display() {
document.getElementById("myid").style.color = "red";
}
</script>
</body>
</html>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP