zoukankan      html  css  js  c++  java
  • js五角星评分特效

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script type="text/javascript">
            var isclick = false;
            function initEvent() {
                var tableWjx = document.getElementById("tableWjx");
                var tds = tableWjx.getElementsByTagName("td");
                for (var i = 0; i < tds.length; i++) {
                    var td = tds[i];
                    td.onmouseover = change;
                    td.onmouseout = repeal;
                    td.onclick = change1;
                }       
            }
            function change() {
                if (!isclick) {
                    var tableWjx = document.getElementById("tableWjx");
                    var tds = tableWjx.getElementsByTagName("td");
                    var index = indexof(tds, this);
                    for (var i = 0; i < index + 1; i++) {
                        var td = tds[i];
                        td.innerText = "★";
                    }
                }
            }
            function repeal() {
                if (!isclick) {
                    var tableWjx = document.getElementById("tableWjx");
                    var tds = tableWjx.getElementsByTagName("td");
                    var index = indexof(tds, this);
                    for (var i = 0; i < index + 1; i++) {
                        var td = tds[i];
                        td.innerText = "☆";
                    }
                }
            }
            function indexof(arr, ele) {
                for (var i = 0; i < arr.length; i++) {
                    if (arr[i] == ele) {
                        return i;
                    }
                }
                return -1;
            }
            function change1() {
                if (!isclick) {
                    change();
                    isclick = true;
                }
                else {
                    alert("Sorry,You had clicked me!");
                }
            }
        </script>
    </head>
    <body onload="initEvent()">
    <table id="tableWjx"><tr><td>☆</td><td>☆</td><td>☆</td><td>☆</td><td>☆</td></tr></table>
    </body>
    </html>

    如果觉得我做的五角星不好看,完全可以把五角星的位置换成图片路径

  • 相关阅读:
    vsc连接wsl时node进程占用cpu高
    LifeCycles属性
    让kbmMWClientQuery更新视图
    uniGUI免登录的实现
    uniGUI 快速定制手机端输入界面布局
    更新IDE的背景
    Delphi 10.4.1来了
    如何修改windows服务器最大的tcp连接数
    uniGUI怎么升级jquery
    【转】UniGUI的布局使用说明
  • 原文地址:https://www.cnblogs.com/yichengbo/p/2177310.html
Copyright © 2011-2022 走看看