zoukankan      html  css  js  c++  java
  • 鼠标表格换色案例

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script src="../js/jquery-3.3.1.min.js"></script>
    </head>
    <body>
    <table border="1px" width="500px" align="center">
        <tr>
            <td><input type="checkbox" id="all"/></td>
            <td>商品名称</td>
            <td>商品价格</td>
            <td>商品数量</td>
            <td>商品操作</td>
        </tr>
    
        <tr>
            <td><input type="checkbox" class="one"/></td>
            <td>Mac</td>
            <td>18000</td>
            <td>20</td>
            <td>
                <a href="#">删除</a>
                <a href="#">修改</a>
            </td>
        </tr>
    
    
        <tr>
            <td><input type="checkbox" class="one"/></td>
            <td>Mac</td>
            <td>18000</td>
            <td>20</td>
            <td>
                <a href="#">删除</a>
                <a href="#">修改</a>
            </td>
        </tr>
    
    
        <tr>
            <td><input type="checkbox" class="one"/></td>
            <td>Mac</td>
            <td>18000</td>
            <td>20</td>
            <td>
                <a href="#">删除</a>
                <a href="#">修改</a>
            </td>
        </tr>
    
    
        <tr>
            <td><input type="checkbox" class="one"/></td>
            <td>Mac</td>
            <td>18000</td>
            <td>20</td>
            <td>
                <a href="#">删除</a>
                <a href="#">修改</a>
            </td>
        </tr>
    
    </table>
    </body>
    <script>
        $("#all").click(function () {
            $(".one").prop("checked", $("#all").prop("checked")); //将最上面checkbox的属性值传递给下面的checkbox的属性
        })
    
        $("tr:even").css("backgroundColor", "green");
        $("tr:odd").css("backgroundColor", "yellow");
    
        var c = null;
        $("tr").mouseover(function () {
            c = $(this).css("backgroundColor");  //换色之前先拿到之前的颜色;
            $(this).css("backgroundColor", "red");
        })
        $("tr").mouseout(function () {
            this.style.backgroundColor = c
        })
    
        //动画效果
        setInterval(function () {
            $("table").hide(3000,"swing",function () {  //退出时间用3″,退出后执行下一个function
                setInterval(function () {
                    $("table").show()
                })
            })
        },3000) //3″后退出
    
    </script>
    </html>
  • 相关阅读:
    剑指offer_11:二进制中1的个数
    剑指offer_10:矩形覆盖
    spring mvc 访问静态资源
    spring context:component-scan ex
    spring aop配置未生效
    415 Unsupported Media Type
    spring mvc 接收List对象入参
    JIRA甘特图
    JIRA的工时
    JIRA导出工作日志到Excel
  • 原文地址:https://www.cnblogs.com/21556guo/p/13453928.html
Copyright © 2011-2022 走看看