zoukankan      html  css  js  c++  java
  • js 淘宝评分

    <!DOCTYPE HTML>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <title>无标题文档</title>
            <script>
                window.onload = function (){
                    var oUl = document.getElementById("list");
                    var aLi = oUl.getElementsByTagName("li");
                    var half = 2;
                    var off = 1;
    
                    for(var i = 0; i < aLi.length; i++)
                    {
                        aLi[i].index = i;
                        aLi[i].onmouseover = function (){
                            if(off)
                            {
                                fillstar(this.index,half);
                            }
                            
                            
                        
                        }
    
                        aLi[i].onmouseout = function (){
    
                            if(off)
                            {
                                for(var i = 0; i < aLi.length; i++ )
                                {
                                aLi[i].style.background = "url(http://img.alicdn.com/tps/i1/T1r.UsXf4dXXcC1lsa-204-400.png) no-repeat";
                                }
                            }
    
                            
                        }
    
                        aLi[i].onclick = function (){
                            if(off)
                            {
                                fillstar(this.index,half);    
                                off = !off;
                            }
                            
                        }
    
                        function fillstar(num,half){
    
                            if( num < half )
                            {
                                for(var i = 0; i <= num; i++)
                                {
                                    aLi[i].style.background = "url(http://img.alicdn.com/tps/i1/T1r.UsXf4dXXcC1lsa-204-400.png) no-repeat 0px -116px";
                                }
                                
    
                            }else if ( num >= half && num < aLi.length - 1 ){
                                
                                for(var i = 0; i <= num; i++)
                                {
                                    aLi[i].style.background = "url(http://img.alicdn.com/tps/i1/T1r.UsXf4dXXcC1lsa-204-400.png) no-repeat 0px -57px";
                                }
                            }else {
    
                                for(var i = 0; i <= num; i++)
                                {
                                    aLi[i].style.background = "url(http://img.alicdn.com/tps/i1/T1r.UsXf4dXXcC1lsa-204-400.png) no-repeat 0px -87px";
                                }
                            }
                        }
                    }
    
    
    
                    
    
                }
            </script>
            <style>
                #list{list-style: none;}
                #list li{
                    height: 23px;
                     24px;
                    background: url(http://img.alicdn.com/tps/i1/T1r.UsXf4dXXcC1lsa-204-400.png) no-repeat;
                    display: block;
                    float: left;
                    cursor: pointer;
    
                }
            </style>
        </head>
        <body>
            <ul id = "list">
                <li></li>
                <li></li>
                <li></li>
                <li></li>
                <li></li>
            </ul>
        </body>
    </head>
  • 相关阅读:
    NAMESPACE
    所谓has a 和 is a
    C++ 的多重继承
    c# 与 c++ 编译
    初始化的顺序:和定义的顺序以及初始化函数都有关系。都要先定义的在前,后定义的在后。甚至连类的顺序都必须这样。
    关于转换
    隐藏
    第四章第四个例题(LRJ)
    初来扎到啊(觉得有些神圣尼)
    理解JS的执行环境
  • 原文地址:https://www.cnblogs.com/mayufo/p/4418178.html
Copyright © 2011-2022 走看看