zoukankan      html  css  js  c++  java
  • 滑动变色——js和jquery对比

    Jquery方法

    <head>
        <script src="jquery-1.4.1.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {

                // 不需要on——
                $(".table1 tr").mouseenter(function () {
                    $(this).css("backgroundColor", "yellow");
                }).mouseleave(function () {
                    $(this).css("backgroundColor", "white");
                });
            })
        </script>
    </head>
    <body>
        <table class="table1">
            <tr>
                <td>
                    喜洋洋
                </td>
            </tr>
            <tr>
                <td>
                    喜洋洋
                </td>
            </tr>
            <tr>
                <td>
                    喜洋洋
                </td>
            </tr>
            <tr>
                <td>
                    喜洋洋
                </td>
            </tr>
            <tr>
                <td>
                    喜洋洋
                </td>
            </tr>
        </table>
    </body>

    Js方法

    <head>
        <script type="text/javascript">
            function ChangeColor() {
                var table = document.getElementByIdx_x("table1");
                var trs = table.getElementsByTagName("tr");
                for (var i = 0; i < trs.length; i++) {
                   

                   // 事件前面有on——
                    trs[i].onmouseenter = function () {
                        this.style.backgroundColor = "yellow";
                    }
                    trs[i].onmouseleave = function () {
                        this.style.backgroundColor = "white";
                    }
                }
            }
        </script>
    </head>

    转自:http://blog.sina.com.cn/s/blog_67aaf4440100r79v.html

  • 相关阅读:
    F12
    InnerClass.java
    Java8
    对象下—练习4
    对象下—练习3
    模板方法
    对象下—练习2
    对象下—举例二、三
    【J-Link】J-Link不支持(版本太低)
    【Android】安装插件 + 改变文字大小、颜色 + 隐藏代码区块的直线
  • 原文地址:https://www.cnblogs.com/12go/p/2254017.html
Copyright © 2011-2022 走看看