看看js代码 alert(obj),显示undfined
<script type="text/javascript">
window.onload=function(){
var nav=document.getElementById("nav2");
var subli=nav2.getElementsByTagName("li");
var sublilength=subli.length;
var i=0;
for(;i<sublilength;i++){
obj= subli[i].getElementsByTagName("ul")[0];//判断一级li导航下面是否包含ul标签;
if(obj){//判断一级li导航下面是否包含ul标签;
subli[i].onmouseover=function(){alert(obj)};//这里就undefined,不理解,就指教
subli[i].onmouseout=function(){this.getElementsByTagName("ul")[0].style.display="block"};//非要这样写才有效果
}
}
}
</script>