首页 > 其他 > 详细

自定义属性应用

时间:2020-01-14 17:12:10      阅读:64      评论:0      收藏:0      [点我收藏+]

<script> 

window.onload = function (){ 

    var aBtn = document.getElementsByTagName(‘input‘); 

    var arr = [ ‘A‘, ‘B‘, ‘C‘, ‘D‘ ]; 

     

    for( var i=0; i<aBtn.length; i++ ){ 

         

        aBtn[i].num = 0; 

         

        aBtn[i].onclick = function (){ 

            // alert( arr[ this.num ] ); 

            this.value = arr[ this.num ]; 

             

            this.num++; 

            if( this.num === arr.length ){ 

                this.num = 0; 

            } 

        }; 

    } 

}; 

</script> 

</head> 

 

<body> 

 

<input type="button" value="0" /> 

<input type="button" value="0" /> 

<input type="button" value="0" /> 

 

</body> 

自定义属性应用

原文:https://www.cnblogs.com/tongguilin/p/12192981.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!