JavaScript Reference Manual
/ onmouseover 事件
onmouseover 事件
onmouseover 事件
實(shí)例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script> function bigImg(x){ x.style.height="64px"; x.style.width="64px"; } function normalImg(x){ x.style.height="32px"; x.style.width="32px"; } </script> </head> <body> <img onmouseover="bigImg(this)" onmouseout="normalImg(this)" border="0" src="smiley.gif" alt="Smiley" width="32" height="32"> <p>函數(shù) bigImg() 在鼠標(biāo)指針移動(dòng)到笑臉圖片是觸發(fā)。</p> <p>函數(shù) normalImg() 在鼠標(biāo)指針移出笑臉圖片是觸發(fā).</p> </body> </html>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例
定義和用法
onmouseover 事件會在鼠標(biāo)指針移動(dòng)到指定的元素上時(shí)發(fā)生。
語法
HTML 中:
<elementonmouseover="SomeJavaScriptCode">
JavaScript 中:
object.onmouseover=function(){SomeJavaScriptCode};
參數(shù) | 描述 |
---|---|
SomeJavaScriptCode | 必需。規(guī)定該事件發(fā)生時(shí)執(zhí)行的 JavaScript。 |
瀏覽器支持
The onmouseover event 所有主要瀏覽器都支持
支持該事件的 HTML 標(biāo)簽:
onmouseover 屬性可使用于是有 HTML 元素,除了: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, 和 <title>.