<ul> | |
<li></li> | |
<li></li> | |
<li></li> | |
</ul> | |
<script> | |
var aLi = document.getElementsByTagName("li"); | |
for(var i=0;i<aLi.length;i++){ | |
aLi[i].index = i; | |
aLi[i].onclick = function (){ | |
this.style.backgroundColor = "yellow"; | |
this.innerHTML = this.index; | |
} | |
} | |
</script> |
索引值
猜你喜欢
转载自blog.csdn.net/cosmos033/article/details/80397580
今日推荐
周排行