0411-11

分类:Javascript作者:admin 阅读次数:30836 views评论次数:2

JS随机标签云

  <script type="text/javascript">
    window.onload=function(){
      var obox=document.getElementById("wrap");
      var obj=obox.getElementsByTagName("a");
      //随机方法
      function rand(num){
       return parseInt(Math.random()*num+1);
      }
      //随机颜色值
      function randomcolor(){
        var str=Math.ceil(Math.random()*16777215).toString(16);
        if(str.length<6){
          str="0"+str;
        }
        return str;
      }
      //循环
      for( len=obj.length,i=len;i--;){
        obj[i].className="color"+rand(5);
        obj[i].style.zIndex=rand(5);
        obj[i].style.fontSize=rand(12)+12+"px";
       // obj[i].style.background="#"+randomcolor();
        obj[i].style.color="#"+randomcolor();
        obj[i].onmouseover=function(){
          this.style.background="#"+randomcolor();
        }
        obj[i].onmouseout=function(){
          this.style.background="none";
        }
      }
    }
  </script>

2条评论
  1. Xexilia 说:
    Gee whiz, and I thugoht this would be hard to find out.
    POST:2011-07-12 19:23:57
  1. vdpmfbnxmd 说:
    XKXRDW hlkbqrvjtsbj
    POST:2011-08-12 08:40:05
发表评论

必填

必填