zoukankan      html  css  js  c++  java
  • onmouseover 事件

    定义和用法

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

    语法

    onmouseover="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

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

    <img src="/i/eg_mouse2.jpg" alt="mouse"
    onmouseover="alert('您的鼠标在图片上!')" />

    输出:(请把鼠标移动图片上):

    Visit W3School!

    实例 2

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

    <html>
    <head>
    <script type="text/javascript">
    function mouseOver()
    {
    document.getElementById('b1').src ="/i/eg_mouse.jpg"
    }
    function mouseOut()
    {
    document.getElementById('b1').src ="/i/eg_mouse2.jpg"
    }
    </script>
    </head>
    
    <body>
    <a href="http://www.w3school.com.cn" 
    onmouseover="mouseOver()" onmouseout="mouseOut()">
    <img alt="Visit W3School!" src="/i/eg_mouse2.jpg" id="b1" />
    </a>
    </body>
    </html>

    输出:

    Visit W3School!

    TIY

    onmouseover
    如何使用 onmouseover。
  • 相关阅读:
    使用60赫兹交流电的关西人
    UI交互细节节选控件使用细则
    PNG button (按钮) files with transparency, for Visual C++ 6.0 and VS2005
    成都第二天:美食
    精力管理与状态转换
    再议“专注”
    成都第一天:印象
    Flash AMF协议
    AS3.0 JSON介绍
    AS3.0 利用AMFPHP与PHP进行通讯 .
  • 原文地址:https://www.cnblogs.com/mfryf/p/3119920.html
Copyright © 2011-2022 走看看