CSS样式
<style>
*{
margin: 0;
padding: 0;
}
.C{
width: 100px;
height: 100px;
/* background:#f3f6ef; */
}
</style>
js函数
<script>
var DIV = document.getElementsByClassName("C");
var i = 0;
DIV[0].onclick = function(){
ChangeBack(this);
}
DIV[1].onclick = function(){
ChangeBack(this);
}
DIV[2].onclick = function(){
ChangeBack(this);
}
DIV[3].onclick = function(){
ChangeBack(this);
}
DIV[4].onclick = function(){
ChangeBack(this);
}
function ChangeBack(obj){
i++;
console.log("点击了"+i+"