jquery-获取随机色,并已加入刷新按钮

Original 2019-04-20 22:00:23 238
abstract:<!DOCTYPE html><html>   <head>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   &nbs

<!DOCTYPE html>
<html>
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>获取随机色</title>
     <script type="text/javascript" src="js/jquery.js"></script>
    <style type="text/css">
  a {
   float:left;
   display:block;
   margin:250px;
   width:500px;
   line-height: 500px;
   text-align: center;
   height:500px;
   color:#fff;
            border-radius: 50px;
            text-decoration: none;
  }
                button{
                    width: 300px;
                    height:100px;
                    background:#00ff00;
                   
                }
    </style>

    <script type="text/javascript">
     //改变标签的背景颜色
        $(document).ready(function(){
            $('button').click(function(){
               function aa(tag) {
           var len=document.getElementsByTagName(tag).length
           for(var i=0;i<len;i++){
            document.getElementsByTagName(tag)[i].style.backgroundColor='rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+')'
           }
        }
        $(document).ready(function(){
            aa('a')
           $('a').mouseover(function(){
            $bg=$(this).css('backgroundColor')
            $(this).css('box-shadow','0px 0px 20px '+$bg)
            $(this).css('border-radius','20px ')
           })
            $('a').mouseleave(function(){
            $(this).css('box-shadow','none')
            $(this).css('border-radius','250px ')
           })
        })
    })
    })
    </script>
   </head>
   <body>
       <button>刷新</button>
     <a href="#">1</a>
  <a href="#">2</a>
  <a href="#">3</a>
  <a href="#">4</a>
   </body>
</html>


Correcting teacher:西门大官人Correction time:2019-04-22 10:06:57
Teacher's summary:随机色的原理是什么?最好简单写一下。还有js代码要加上分号,规范。群里说过很多次了

Release Notes

Popular Entries