日期:2014-05-16 浏览次数:20493 次
<div id="nav">
<ul>
<li><a href="#">111111</a></li>
<li><a href="#">2222</a></li>
</ul>
</div>
<script type="text/javascript">
var aobj=document.getElementById("nav").getElementsByTagName("a");
aobj.onclick=function(){
alert('你单击了我');
}
</script>
var divNav = document.getElementById("nav");
var objLi = null;
for (var i = 0; i < divNav.children[0].children.length; i++)
{
objLi = divNav.children[0].children[i];
objLi.children[0].onclick = function()
{
alert('你单击了我');
}
}