标签:class div javascrip func document fun padding font doc
<ul id="ul">
<li>1111</li>
<li>2222</li>
<li>3333</li>
<li>4444</li>
<li>5555</li>
</ul>
初学者写法:
<script type="text/javascript">
var oUl = document.getElementById("ul");
var aLi = oUl.getElementsByTagName("li");
for(var i = 0; i < aLi.length; i++){
aLi[i].onclick = function (){
alert(i);
};
}
</script>
标签:class div javascrip func document fun padding font doc
原文地址:https://www.cnblogs.com/resist/p/9174525.html