HTML onmouseover 事件属性
当鼠标指针移至图片之上时运行脚本:
<!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="/examples/smiley.gif" alt="Smiley" width="32" height="32">
<p>当用户将鼠标移动到图片上时触发 bigImg() 函数。该函数使图片变大。</p>
<p>当用户将鼠标移开图片时触发 normalImg() 函数。该函数使图片变回原来大写。</p>
</body>
</html>
浏览器支持
![]()
![]()
![]()
![]()
![]()
所有主流浏览器都支持 onmouseover 事件属性
定义和用法
onmouseover 属性在鼠标指针移至元素之上时触发。
注意: onmouseover 属性不能使用于以下元素:<base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, 或<title>。
HTML 4.01 与 HTML5之间的差异
无。
语法
<element onmouseover="script">
属性值
| 值 | 描述 |
|---|---|
| script | 规定该onmouseover事件触发时执行的脚本。 |
HTML 事件属性