onmouseover 事件

定义和用法

onmouseover 事件会在鼠标指针移动到指定的对象上时发生。

语法

οnmοuseοver="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

实例 1

在下面的例子中,我们将在用户把鼠标指针移动到图像上时显示一个对话框:

1 <img src="http://www.w3school.com.cn/i/eg_mouse2.jpg" alt="mouse" onmouseover="alert('您的鼠标在图片上!')" />

实例 2

下面的例子中,我们将在网页上添加一个用作连接按钮的图像,然后我们会添加 onMouseOver 和 onMouseOut 事件,这样就可以在运行两个 JavaScript 函数来切换两幅图像:

 1 <html>
 2 <head>
 3 <script type="text/javascript">
 4 function mouseOver()
 5 {
 6 document.getElementById('b1').src ="/i/eg_mouse.jpg"
 7 }
 8 function mouseOut()
 9 {
10 document.getElementById('b1').src ="/i/eg_mouse2.jpg"
11 }
12 </script>
13 </head>
14 
15 <body>
16 <a href="http://www.w3school.com.cn" 
17 onmouseover="mouseOver()" onmouseout="mouseOut()">
18 <img alt="Visit W3School!" src="/i/eg_mouse2.jpg" id="b1" />
19 </a>
20 </body>
21 </html>

 

转载于:https://www.cnblogs.com/gmblog/p/3826121.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值