onmouseout 事件
定義和用法
onmouseout 事件會在鼠標(biāo)指針移出指定的對象時發(fā)生。
語法
onmouseout="SomeJavaScriptCode"
參數(shù) | 描述 |
---|---|
SomeJavaScriptCode | 必需。規(guī)定該事件發(fā)生時執(zhí)行的 JavaScript。 |
支持該事件的 HTML 標(biāo)簽:
<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>
支持該事件的 JavaScript 對象:
layer, link
實例 1
在下面的例子中,我們將在鼠標(biāo)指針移出圖像時顯示一個對話框:
<img src="/i/example_mouse2.jpg" alt="mouse"
onmousemove="alert('您的鼠標(biāo)剛才離開了圖片!')"
/>
輸出:(請把鼠標(biāo)從圖片上移開):

實例 2
下面的例子中,我們將在網(wǎng)頁上添加一個用作連接按鈕的圖像,然后我們會添加 onMouseOver 和 onMouseOut 事件,這樣就可以在運行兩個 JavaScript 函數(shù)來切換兩幅圖像:
<html>
<head>
<script type="text/javascript">
function mouseOver()
{
document.getElementById('b1').src ="/i/eg_mouse.jpg"
}
function mouseOut()
{
document.getElementById('b1').src ="/i/eg_mouse2.jpg"
}
</script>
</head>
<body>
<a href="http://www.dbjr.com.cn"
onmouseover="mouseOver()" onmouseout="mouseOut()"
>
<img alt="Visit w3school!" src="/i/example_mouse2.jpg" id="b1" />
</a>
</body>
</html>
輸出:

TIY
- onmouseout
- 如何使用 onmouseout。