600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > HTML onmouseover onmouseout onmousemove 事件属性

HTML onmouseover onmouseout onmousemove 事件属性

时间:2020-09-01 07:44:14

相关推荐

HTML onmouseover  onmouseout   onmousemove 事件属性

HTML onmouseover 事件属性

定义和用法

onmouseover 属性在鼠标指针移动到元素上时触发。

注释:onmouseover 属性不适用以下元素:<base>、<bdo>、<br>、<head>、<html>、<iframe>、<meta>、<param>、<script>、<style> 或 <title>。

语法

<element οnmοuseοver="script">

属性值

实例

当鼠标指针移动到图像上时执行一段 JavaScript(使图像放大):

<!DOCTYPE html><html><head><script>function bigImg(x){x.style.height="180px";x.style.width="180px";}function normalImg(x){x.style.height="128px";x.style.width="128px";}</script></head><body><img οnmοusemοve="bigImg(this)" οnmοuseοut="normalImg(this)" border="0" src="/i/eg_smile.gif" alt="Smiley" ><p>函数 bigImg() 在鼠标指针移动到图像上时触发。此函数放大图像。</p><p>函数 normalImg() 在鼠标指针移出图像时触发。此函数把图像的高度和宽度重置为正常尺寸。</p></body></html>

onmouseout 事件

定义和用法

onmouseout 事件会在鼠标指针移出指定的对象时发生。

语法

οnmοuseοut="SomeJavaScriptCode"

支持该事件的 HTML 标签:

<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

支持该事件的 JavaScript 对象:

layer, link

实例

在下面的例子中,我们将在鼠标指针移出图像时显示一个对话框:

[html]view plaincopy<imgsrc="/i/example_mouse2.jpg"alt="mouse"onmousemove="alert('您的鼠标刚才离开了图片!')"/>

HTML onmousemove 事件属性

定义和用法

onmousemove 属性在鼠标指针移动到元素上时触发。

注释:onmousemove 属性不适用以下元素:<base>、<bdo>、<br>、<head>、<html>、<iframe>、<meta>、<param>、<script>、<style> 或 <title>。

语法

<element οnmοusemοve="script">

属性值

实例

当鼠标指针移动到图像上时执行一段 JavaScript(使图像放大):

[html]view plain copy<!DOCTYPEhtml> <html> <head> <script> functionbigImg(x) { x.style.height="180px"; x.style.width="180px"; } functionnormalImg(x) { x.style.height="128px"; x.style.width="128px"; } </script> </head> <body> <imgonmousemove="bigImg(this)"onmouseout="normalImg(this)"border="0"src="/i/eg_smile.gif"alt="Smiley"> <p>函数bigImg()在鼠标指针移动到图像上时触发。此函数放大图像。</p> <p>函数normalImg()在鼠标指针移出图像时触发。此函数把图像的高度和宽度重置为正常尺寸。</p> </body> </html>

本文转自w3shool

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。