摘要:<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>按钮获取随机数</title> <script type="
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>按钮获取随机数</title>
    <script type="text/javascript" src="../jquery-3.4.1.min.js"></script>
    <style type="text/css">
 a{float: left;
 display: block;
 margin: 50px;
 width: 100px;
 line-height: 100px;
 text-align: center;
 height: 100px;
 color: black;
 border-radius: 50px;
 text-decoration: none;
        }
        .btn{border: none;background-color: orange;color: green}
 </style>
    <script type="text/javascript">
 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)+')'
 }
       }
 function bb(tag1){
 var len = document.getElementsByTagName(tag1).length;
 for (var i=0;i<len;i++){
 document.getElementsByTagName(tag1)[i].innerText= Math.floor(Math.random()*100);
           }
       }
 $(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','50px')
               });
 $('button').click(function () {
 aa('a');
 bb('a');
               })
       })
 </script>
</head>
<body>
    <a href="#">1</a>
    <a href="#">2</a>
    <a href="#">3</a>
    <a href="#">4</a>
    <a href="#">5</a><br><br><br><br>
    <button class="btn">获取随机</button>
</body>
</html>
						批改老师:天蓬老师批改时间:2019-05-28 16:56:45		
						
老师总结:获取随机的颜色, 是通过调用一个js内置函数来实现的,   本质上与jQuery无关					
 
                 
 
 
  
            