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

  • 相关阅读:
    存储过程生成POCO
    Asp.net MVC4与Razor呈现图片的扩展
    Html5中新input标签与Asp.net MVC应用程序
    HTML5上传文件显示进度
    JQuery图表插件之Flot
    用Html5与Asp.net MVC上传多个文件
    TSQL列出最后访问的存储过程
    Asp.net MVC 限制一个方法到指定的Submit按钮
    VisualStudio2012轻松把JSON数据转换到POCO的代码
    Apache Tika源码研究(三)
  • 原文地址:https://www.cnblogs.com/12go/p/2254017.html
Copyright © 2011-2022 走看看