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复习--评分控件(类似于淘宝给好差平的星星),古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。