日期:2014-05-16  浏览次数:20340 次

ie8浏览器 js报参数无效的问题(请js高手指点)!!!
function change(x){
var a = document.getElementById('sidebar-wrapper').document.getElementsByTagName('a');
for(var i=0;i<a.length;i++){
   var aid = a[i].id;
   if(aid==x){
      document.getElementById(aid).className = 'nav-top-item current';
   }else{
      document.getElementById(aid).className = 'nav-top-item';
   }
}
}

我的目的是 遍历<div> id为‘sidebar-wrapper’下所有<a>标签, x参数为<a>标签的id, 通过onclick事件判断是我选中的就修改class的值,来改变样式。经过调试 总是提示红色部分 参数无效!!!

请教js高手帮我看看,问题出在哪里?????非常感谢(本人初学js遇到这样问题很是郁闷,查过很多资料,仍没找到问题所在!!!) 
------解决方案--------------------
var a = document.getElementById('sidebar-wrapper').document.getElementsByTagName('a');