<body> | |
<button type="button">按钮1</button> | |
<button type="button">按钮2</button> | |
<button type="button">按钮3</button> | |
<script> | |
var aBtn = document.getElementsByTagName("button"); | |
var that = null; | |
function changeBg(){ | |
that.style.backgroundColor = "yellow"; | |
} | |
for(var i=0;i<aBtn.length;i++){ | |
aBtn[i].onclick = function (){ | |
that = this; | |
changeBg(); | |
}; | |
} | |
</script> |
09-06