HTML OnMouseOver 事件属性|鼠标移至元素之上时运行脚本
定义与用法
onmouseover 属性在鼠标指针移至元素之上时触发。
提示: onmouseover 属性不能使用于以下元素:<base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, 或<title>。
语法格式
<element onmouseover=”script“>
示例代码
<script>
function bigImg(x) {
x.style.height = "64px";
x.style.width = "64px";
}
function normalImg(x) {
x.style.height = "32px";
x.style.width = "32px";
}
</script>
效果展示:
当用户将鼠标移动到图片上时触发 bigImg() 函数。该函数使图片变大。
当用户将鼠标移开图片时触发 normalImg() 函数。该函数使图片变回原来大写。
浏览器支持
事件属性 | |||||
---|---|---|---|---|---|
OnMouseOver | Yes | Yes | Yes | Yes | Yes |
所有主流浏览器都支持 onmouseover 事件属性
属性值
值 | 描述 |
---|---|
script | 规定该onmouseover事件触发时执行的脚本。 |