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