• jQuery学习-鼠标事件


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title>鼠标事件</title>
                <script src="js/jquery.js"></script>
            
            <style>
            .me{ 
                
                border: 1px solid red;
                margin-top: 75px;
                 400px;
                height: 150px;
                background-color: #ccc;
                overflow: auto;
            }
            </style>
            
            <script type="text/javascript">    
                //页面加载完成简写形式
                $(function(){
                    $("button").on("click",function(){
                        
                        $("input").css("background-color","lightblue");
                    });
                    
                    
                    //移动进入的时候触发mouseover,移出时触发mouseout
                    //在jQuery中提供了个hover() 带两个参数 是 鼠标移动进入时执行的函数和鼠标移动出执行的函数
                    $(".me").hover(function(){
                        //移入执行的函数
                        $(this).css("background-color","red");
                    },function(){
                        //移出执行的函数
                        $(this).css("background-color","#ccc");
                    })
                    
                    //给整个文档绑定鼠标移动事件
                    //在事件处理函数中有一个默认参数 事件对象event 它包含了事件产生的信息
                    $(document).on("mousemove",function(event){
                        
                        var x=event.pageX//鼠标在文档X坐标
                        var y=event.pageY//鼠标Y坐标
                        $("#div1").text("X:"+x+"Y:"+y);
                        
                    });
                    
                    //双击放大DIV
                    $(".me").on("dblclick",function(){
                        
                        $(this).width(600);
                        $(this).height(300);
                    });
                    
                    //停止双击事件向父层传播
                    $("button").dblclick(function(event){
                        
                        event.stopPropagation();
                    });
                
                })
            
            </script>
        </head>
        <body>
            <div>
                <div id="div1">在这里显示坐标</div>
                <div class="me">事件测试案例
                <input type="text" /><br>
                <button>提交</button>
                </div>
            </div>
        </body>
    </html>
  • 相关阅读:
    模板-树链剖分
    bzoj2523 聪明的学生
    P1220 关路灯
    BZOJ3572 [Hnoi2014]世界树
    BZOJ4013 [HNOI2015]实验比较
    BZOJ4012 [HNOI2015]开店
    BZOJ4011 [HNOI2015]落忆枫音
    BZOJ4009 [HNOI2015]接水果
    BZOJ4010 [HNOI2015]菜肴制作
    BZOJ4008 [HNOI2015]亚瑟王
  • 原文地址:https://www.cnblogs.com/whzym111/p/6070418.html
Copyright © 2020-2023  润新知