新手求教,一个js问题
<div id="rt-main-header">
<div class="menu">
<ul class="menutop">
<li class="root"><p class="item "><span>网站首页</span></p> </li>
<li class="root" ><p class=" item " ><span>完善个人资料</span></p>
</li>
<li class="root"><p class=" item "><span>社团列表</span></p>
</li>
<li class="root" ><p class=" item "><span>社团活动</span></p>
</li>
<li class="root"><p class=" item "><span>所在社团成员</span></p>
</li>
<li class="root" ><p class=" item " ><span>留言板</span></p></li>
</ul>
</div>
</div>
为什么我用js处理不了li里面的span的内容呢?
以下为js代码
window.onload=funtion()
{
var oUl = document.getElementsByTagName('ul')[0];
var aLi = oUl.getElementsByTagName('li');
for(i=0;i<aLi.length;i++) {
aLi[i].onmouseover=function(){
alert(1);
}
}
}
------解决方案--------------------<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
window.onload=function()
{
var oUl = document.getElementsByTagName('ul')[0];
var aLi = oUl.getElementsByTagName('li');
for(i=0;i<aLi.length;i++) {
aLi[i].onmouseover=function(){
alert(1);
}
}
}
</script>
</head>
<body>
<div id="rt-main-header">
<div class="menu">
<ul class="menutop">
<li class="root"><p class="item "><span>网站首页</span></p> </li>
<li class="root" ><p class=" item " ><span&