zoukankan      html  css  js  c++  java
  • 鼠标事件(jQuery方法)

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" lang="en">

        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <title>鼠标事件</title>
            <script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
            <script type="text/javascript">
                $(function() {
                    $("input[type='button']")
                        .css("width", "280px")
                        .css("height", "100px")
                        .css("font-size", "24pt");

                    $("input[type='button']:eq(0)")
                        .mouseover(fnOver)
                        .mouseout(fnOut);

                    $("input[type='button']:eq(1)")
                        .click(function() {
                            $('h1').html('点击了鼠标!');
                        });

                    $("input[type='button']:eq(2)")
                        .dblclick(function() {
                            $('h1').html('双击了鼠标!');
                        });
                    $("input[type='button']:eq(3)")
                        .mousedown(function() {
                            $('h1').html('按下了鼠标!');
                        })
                        .mouseup(function() {
                            $('h1').html('松开了鼠标!');
                        });
                    $("div").mousemove(function() {
                        $("div").text(event.x + "," + event.y);
                    });
                });

                function fnOver() {
                    $("h1").html("鼠标移动到按钮上了!");
                }

                function fnOut() {
                    $("h1").html("鼠标移开了!");
                }

                function fnMove() {
                    $("div").text(event.x + "," + event.y);
                }
            </script>
        </head>

        <body>
            <h1></h1>
            <input type="button" value="测试悬停" />
            <input type="button" value="测试点击" />
            <input type="button" value="测试双击" />
            <input type="button" value="测试鼠标按键" />
            <div style="border: double 3px red; 400px; height: 300px;">
            </div>
        </body>

    </html>

  • 相关阅读:
    数值的整数次方
    二进制中1的个数
    SpingBoot 启动自动给MongoDB建库
    Java 依赖冲突的解决办法
    Http协议
    你被限流了吗?
    LeetCode 783. 二叉搜索树节点最小距离
    Leetcode 687. 最长同值路径
    LeetCode 784. 字母大小写全排列
    LeetCode 面试题 08.06. 汉诺塔问题
  • 原文地址:https://www.cnblogs.com/zhouguoshuai/p/8192207.html
Copyright © 2011-2022 走看看