• 打星功能


    <!doctype html>
    <html>
    <head>
        <meta charset="gbk">
        <title>切换</title>
        <style>
            .wrapper{300px; margin:10px auto; font:14px/1.5 arial;}
            /*tab*/
            #star{overflow:hidden;}
            #star li{float:left; 20px; height:20px; margin:2px; display:inline; color:#999; font:bold 18px arial; cursor:pointer}
            #star .act{color:#c00}
            #star_word{80px; height:30px; line-height:30px; border:1px solid #ccc; margin:10px; text-align:center; display:none}
    
        </style>
        <script>
            window.onload = function(){
    
                var star = document.getElementById("star");
                var star_li = star.getElementsByTagName("li");
                var star_word = document.getElementById("star_word");
                var result = document.getElementById("result");
                var i=0;
                var j=0;
                var k=0;
                var len = star_li.length;
                var word = ['很差','差','一般',"好","很好"]
    
                for(i=0; i<len; i++){
                    star_li[i].index = i;
                    var luck=true;
                    star_li[i].onmouseover = function(){
    
    
                        for(i=0; i<=this.index; i++){
                            star_li[i].className = "act";
                        }
                    }
    
                    star_li[i].onclick = function () {
                        for (i = 0; i <= this.index; i++) {
                            star_li[i].className = "act";
                        }
                        luck =false;
                        console.log(luck);
    
                    }
    
                      star_li[i].onmouseout = function () {
                          if(luck) {
                          for (i = 0; i <= this.index; i++) {
                              star_li[i].className = "d";
    
                          }
    
                      }else{
                              luck=true;
                          }
                  }
    
    
    
                    }
    
            }
        </script>
    </head>
    <body>
    <div class="wrapper">
        打分结果
        <span id="result"></span>
        <ul id="star">
            <li>★</li>
            <li>★</li>
            <li>★</li>
            <li>★</li>
            <li>★</li>
        </ul>
        <div id="star_word">一般</div>
    
    </div>
    
    
    </body>
    </html>
  • 相关阅读:
    js 一维数组转二维数组
    mongoose 系列设置
    手写系列
    设置未登录的导航守卫
    vue 添加设置别名文件
    移动端视口标签
    小程序跳转页面怎么携带数据
    data数据复杂时怎么setData
    小程序注意的点 text标签中一定 不要换行
    小程序用户登录
  • 原文地址:https://www.cnblogs.com/xisitan/p/4429600.html
Copyright © 2020-2023  润新知