HTML onmouseout 事件属性
HTML onmouseout 事件特性会在 HTML 文档中鼠标指针移出 HTML 元素时触发。
语法
语法如下−
<tagname onmouseout=”script”></tagname>
我们来看一个 HTML onmouseout 事件特性示例−
示例
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: #000;
height: 100vh;
background-color: #FBAB7E;
background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%);
text-align: center;
}
.circle {
background: #db133a;
height: 150px;
width: 150px;
border-radius: 50%;
margin: 10px auto;
}
p {
margin: 30px auto;
}
</style>
</head>
<body>
<h1>HTML onmousemove Event Attribute Demo</h1>
<div class="circle" onmousemove="mouseMoveFn()" onmouseout="mouseOutFn()"></div>
<p>Try to move the cursor over the red circle</p>
<script>
function mouseMoveFn() {
document.querySelector('.circle').style.background = '#2274A5';
}
function mouseOutFn() {
document.querySelector('.circle').style.background = '#0B6E4F';
}
</script>
</body>
</html>输出

现在,尝试将鼠标光标移到红 圆圈上,观察 onmouseout 事件特性如何工作的−


广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP