当鼠标指针悬停在 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