onmouseover屬性用來獲取或設置當前元素的mouseover事件的事件處理函數(shù)
當鼠標指針移至圖片之上時運行腳本:
<!DOCTYPE html> <html> <head> <title>HTML onmouseover 事件屬性的使用(菜鳥教程 cainiaoplus.com)</title> </head> <body> <img onmouseover="bigImg(this)" onmouseout="normalImg(this)" border="0" src="pig.gif" alt="pig" width="32" height="32"> <p>用戶將鼠標懸停在圖像上時,將觸發(fā)bigImg()函數(shù)。此功能放大圖像。 當鼠標指針移出圖像時,將觸發(fā)normalImg()函數(shù)。該功能將圖像的高度和寬度設置為正常。</p> <script> function bigImg(x) { x.style.height = "64px"; x.style.width = "64px"; } function normalImg(x) { x.style.height = "32px"; x.style.width = "32px"; } </script> </body> </html>測試看看 ?/?
IEFirefoxOperaChromeSafari
所有主流瀏覽器都支持 onmouseover 事件屬性
當鼠標指針移到某個元素上時,會觸發(fā)onmouseover屬性。
提示: onmouseover屬性通常與onmouseout屬性一起使用。
注意: onmouseover 屬性不能使用于以下元素:<base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, 或<title>。
沒有。
<element onmouseover="script">
值 | 描述 |
---|---|
script | 規(guī)定該onmouseover事件觸發(fā)時執(zhí)行的腳本。 |