zoukankan      html  css  js  c++  java
  • Jquery 实现鼠标事件

    编写代码

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <script src="jqueryjquery.js"></script>
        <style>
            #div1 {
                background-color: white;
                margin: 20px;
                 200px;
                height: 200px;
                border: pink 5px solid;
            }
        </style>
    </head>
    
    <body>
        <!-- <a href="https://jquery.com">default click action is prevented</a>
        <div id="log"></div>
        <script>
            $("a").click(function(event) {
                event.preventDefault();
                $('<div/>').append('default ' + event.type + ' prevented').appendTo('#log'); //default click prevented
            });
        </script> -->
        <div id="div1"></div>
        <script>
            $(Document).ready(function() {
                // alert("hello");
                $("#div1").click(function() {
                    $(this).css("backgroundColor", "red");
                })
                $("#div1").hover(function() {
                    $(this).css("backgroundColor", "hotpink")
                })
                $("#div1").mouseout(function() {
                        $(this).css("backgroundColor", "white")
                    })
                    // $("div1").one("hover",function(){
                    //     // alert(event.data.a)
                    //     $(this).css("backgroundColor","hotpink")
    
            })
        </script>
    </body>
    
    </html>
    

    运行结果



  • 相关阅读:
    search方法的使用
    边界字符的使用
    重复数量限定符
    常用匹配符
    使用JS快速读取TXT文件
    基于jq和纯js的 读取本地.txt文件的方法
    Linux中的du和df命令
    HSSFWorkbook
    el表达式
    eclipse 导入web项目时常见错误
  • 原文地址:https://www.cnblogs.com/d534/p/15179286.html
Copyright © 2011-2022 走看看