onmousemove屬性用來(lái)獲取或設(shè)置當(dāng)前元素的mousemove事件的事件處理函數(shù)
將鼠標(biāo)指針移到圖像上時(shí)執(zhí)行JavaScript:
<!DOCTYPE html>
<html>
<head>
<title>HTML onmousemove 事件屬性的使用(菜鳥(niǎo)教程 cainiaoplus.com)</title>
</head>
<body>
<img onmousemove="bigImg(this)" onmouseout="normalImg(this)" border="0" src="pig.gif" alt="pig" width="32" height="32">
<p>當(dāng)用戶(hù)鼠標(biāo)指針移到圖像上方時(shí),將觸發(fā)bigImg()函數(shù)。此功能放大圖像。<br>
當(dāng)鼠標(biāo)指針移出圖像時(shí),將觸發(fā)normalImg()函數(shù)。該功能將圖像的高度和寬度設(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>測(cè)試看看 ?/?IEFirefoxOperaChromeSafari
所有主流瀏覽器都支持 onmousemove 事件屬性
當(dāng)指針在元素上移動(dòng)時(shí),onmousemove屬性將觸發(fā)。
注意: onmousemove 屬性不能使用于以下元素: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, 或<title>。
沒(méi)有。
<element onmousemove="script">
| 值 | 描述 |
|---|---|
| script | 規(guī)定該onmousemove事件觸發(fā)時(shí)執(zhí)行的腳本。 |