• 索引值的应用


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <script>
                window.onload = function(){
                    var aBtn = document.getElementsByTagName('input');
                    var aP = document.getElementsByTagName('p');
                    var arr=['kk','li','ll'];
                    for(var i = 0;i<aBtn.length;i++){
                        aBtn[i].index= i;
                        aBtn[i].onclick = function(){
                            this.value = arr[this.index];
                            aP[this.index].innerHTML = arr[this.index];
                        }
                    }
                }
            </script>
        </head>
        <body>
            <input type="button" value="btn1"/>
            <input type="button" value="btn2"/>
            <input type="button" value="btn3"/>
            <p>5</p>
            <p>7</p>
            <p>9</p>
        </body>
    </html>
    示例代码
  • 相关阅读:
    red and black(BFS)
    G
    D
    new word
    CSS Layout
    G
    CSS
    组合数学-母函数
    组合数学-卡特兰数
    cf1144G 将串分解成单调递增和递减子串(贪心)
  • 原文地址:https://www.cnblogs.com/linjiaxiaomeiainia/p/6910280.html
Copyright © 2020-2023  润新知