国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

使用jQuery隨機(jī)獲取顏色

Original 2018-12-02 12:05:20 385
abstract:需要用到j(luò)s的自定義函數(shù)其中還有g(shù)etElementsByTagName()Math.floor(Math.random()*256)而jQuery用到了mouseover方法以及mouseleave方法具體頁(yè)面如下<!DOCTYPE html>    <html>        <head> 

需要用到j(luò)s的自定義函數(shù)

其中還有

getElementsByTagName()

Math.floor(Math.random()*256)

而jQuery用到了

mouseover方法

以及mouseleave方法


具體頁(yè)面如下

<!DOCTYPE html>

    <html>

        <head>

          <meta http-equiv="Content-Type" content="text/html" charset="utf-8">

          <title>隨機(jī)獲取顏色</title>

          <script type="text/javascript" src="jquery-3.3.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:#fff;

              border-radius:50px;

              text-decoration:none;


             }

          </style>

          <script type="text/javascript">

                // 改變標(biāo)簽背景

              function bk(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(){

            bk('a')

            $('a').mouseover(function(){

              $bg=$(this).css('backgroundColor')

              $(this).css('box-shadow','0px 0px 20px '+$bg)

              $(this).css('border-radius','20px 20px 20px ')

            })

            $('a').mouseleave(function(){

              $(this).css('box-shadow','none')

              $(this).css('borser-radius','50px ')

            })

   

        })

          </script>

        </head>

        <body>

           <a herf="#">1</a>

           <a herf="#">2</a>

           <a herf="#">3</a>

           <a herf="#">4</a>

        </body>

    </html>


Correcting teacher:天蓬老師Correction time:2018-12-02 12:22:18
Teacher's summary:下次,生成隨機(jī)值,建議單獨(dú)一行寫(xiě),放在一個(gè)變量中,這樣不易出錯(cuò)

Release Notes

Popular Entries