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>

JavaScript复习--评分控件(类似于淘宝给好差平的星星),布布扣,bubuko.com

JavaScript复习--评分控件(类似于淘宝给好差平的星星)

上一篇:Java 大数加法HdAcm1002


下一篇:windows多线程同步--事件