使用index`
<body>
<div id="main">
<input type="checkbox" class="check-box">
<input type="checkbox" class="check-box">
<input type="checkbox" class="check-box">
<input type="checkbox" class="check-box">
<input type="checkbox" class="check-box">
</div>
</body>
<script>
window.onload = function(){
var inputs = document.getElementsByClassName("check-box");
for(let i=0;i<inputs.length;i++){
inputs[i].setAttribute("index",i);
inputs[i].onclick = function(){
console.log("第"+this.getAttribute("index")+"个");
}
}
}
</script>