zoukankan      html  css  js  c++  java
  • JavaScript复习--评分控件(类似于淘宝给好差平的星星)

     <script type="text/javascript">
            function indexOf(tdds,element)
            {
                for (var i = 0; i < tdds.length; i++)
                {
                    if (tdds[i] == element)
                    {
                        return i;
                    }
                }
            }

            function InitEvent()
            {
                var tds = document.getElementsByTagName("td");
                for (var i in tds)
                {
                    var td = tds[i];
                    td.onmouseover=function()
                    {
                        var index = indexOf(tds, this);

                        for (var j = 0; j <= index; j++) {
                            tds[j].innerText = "★";
                        }

                        for (var k = index + 1; k < tds.length; k++) {
                            tds[k].innerText = "☆";
                        }
                    }
                }
            }
        </script>
    </head>
    <body onload="InitEvent();">
        <table>
            <tr><td>☆</td><td>☆</td><td>☆</td><td>☆</td><td>☆</td></tr>
        </table>
    </body>

  • 相关阅读:
    读取radio的value值
    Bootstrap初学(一)
    移动测试用例
    Python 打包成exe执行文件
    Python 模块导入
    Sublime Text2编辑器
    发送Email
    读写TXT文档
    JS与Jquery
    自动化测试摸索
  • 原文地址:https://www.cnblogs.com/fanshaomin/p/3601341.html
Copyright © 2011-2022 走看看