<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
window.onload = function(){
var aBtn = document.getElementsByTagName('input');
console.log(aBtn);
var arr = ['A','B','C','D'];
for(var i=0; i< aBtn.length; i++){
aBtn[i].num = 0;
aBtn[i].onclick = function(){
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>
</html>