• changXY


     changXY

    <!DOCTYPE html>
    <html>
    
    <head>
      <link rel="shortcut icon" href="./assets/favicon.ico" />
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
      <title>changeXY</title>
    </head>
        <style>
            *{
                padding: 0;
                margin: 0;
            }
            #ul li{ 
               list-style: none;
                 50px;
                height: 50px;
                text-align: center;
                line-height: 50px;
                border-right: none;
                background: papayawhip;
                border: 1px solid #000;
            }
            #ul{
                margin: 200px auto;
                display: flex;
                flex-wrap: wrap;
                overflow: hidden;
                position: relative;
            }
            .button{
                position: absolute;
                top: 14%;
                right: 21%;
                background-color: aquamarine;
            }
           
        </style>
    <body>
    <ul id="ul"></ul>
    <button class='button' onclick="ChangeVlaue()">changeXY</button>
    </body>
    <script>
        let arr=[];
        let size=6;
        let sizeGrid=50
        let len =size*size;
        let ul = document.getElementById('ul')
        let OLi =ul.getElementsByTagName('li')
        ul.style.width = size*(sizeGrid + 2)+'px' ;
        for( let i=0 ;i <len;i++){
            let Oli = document.createElement('li')
            Oli.style.width = sizeGrid +'px';
            Oli.style.height = sizeGrid +'px';
            Oli.innerHTML =i;
            arr.push(i);
            ul.appendChild(Oli)
        }
        function ChangeVlaue(){
            arr = changeXY(arr,size)
            for( let i =0;i<arr.length;i++){
                // console.log("arr[i]-------",arr[i])
                // console.log("OLi[i]--",OLi[i])
                OLi[i].innerHTML = arr[i];
            }
        }
        function changeXY(arr,size){
            let NewArr=[];
            let j =0;
            (function(){
                if(size == j){
                    return;
                }
                for( let i=0 ;i<arr.length;i++){
                    if( i%size == j){
                        NewArr.push(arr[i])
                    }
                }
                j++;
                arguments.callee() /* 匿名函数自调用*/
            })();
            return  NewArr;
        }
        
    </script>
    </html>
    

      

  • 相关阅读:
    ZOJ Problem Set
    数学之美:生活中的技术
    java泛型【收藏】
    "i=i++"在java等高级语言的解释
    poj1001
    ⑧javaWeb之在例子中学习(过滤器Filter)
    ZOJ Problem Set
    IT十年经典书籍
    ⑦JSP2.0的福利(标签文件)
    myeclipse-common 找不到
  • 原文地址:https://www.cnblogs.com/tsgxj/p/10516385.html
Copyright © 2020-2023  润新知