HTML onmouseover, onmouseout , onmousemove 事件属性

HTML onmouseover 事件属性


定义和用法

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

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

语法

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

属性值

描述
script onmouseover 发生时运行的脚本。

实例

当鼠标指针移动到图像上时执行一段 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"
参数 描述
SomeJavaScriptCode 必需。规定该事件发生时执行的 JavaScript。

支持该事件的 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 plain copy
  1. <img src="/i/example_mouse2.jpg" alt="mouse"  
  2. onmousemove="alert('您的鼠标刚才离开了图片!')" />  



HTML onmousemove 事件属性


定义和用法

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

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



语法

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

属性值

描述
script onmousemove 发生时运行的脚本。


实例

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


[html]  view plain  copy
  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <script>  
  5. function bigImg(x)  
  6. {  
  7. x.style.height="180px";  
  8. x.style.width="180px";  
  9. }  
  10.   
  11. function normalImg(x)  
  12. {  
  13. x.style.height="128px";  
  14. x.style.width="128px";  
  15. }  
  16. </script>  
  17. </head>  
  18. <body>  
  19.   
  20. <img onmousemove="bigImg(this)" onmouseout="normalImg(this)" border="0" src="/i/eg_smile.gif" alt="Smiley" >  
  21.   
  22. <p>函数 bigImg() 在鼠标指针移动到图像上时触发。此函数放大图像。</p>  
  23. <p>函数 normalImg() 在鼠标指针移出图像时触发。此函数把图像的高度和宽度重置为正常尺寸。</p>  
  24.   
  25. </body>  
  26. </html>  




本文转自w3shool

  • 5
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值