<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
window.onload=function(){
var lis = document.getElementsByTagName("li");
var odiv = document.getElementById("antzone");
for (let index = 0; index < lis.length; indexPP) {
lis[index].onclick = function () {
odiv.innerHTML = index;
}
}
}
</script>
</head>
<body>
<div id="antzone"></div>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>
ask why the parameter index:
lis.onclick = function (index) {
odiv.innerHTML = index;
}