getElementsByTagName()和getElementById()都没问题,唯独getElementsByClassName()无法执行,用的chrome应该不是浏览器问题,求抓BUG。
<script type="text/javascript">
window.onload = function(){
var la = document.getElementById("jerk");
var lis = document.getElementsByTagName('li');
var divs = document.getElementsByClassName("f-r");
for(i=0;i<lis.length;i++){
divs[i].style.backgroundImage='url(../bg/bg'+i+'.jpg)';
lis[i].index= i;
lis[i].onmouseover = function(){
for(i=0;i<lis.length;i++){
lis[i].className="js";
divs[lis[i].index].style.display = "none";
divs[lis[i].index].className="";
}
this.className='jj';
jerk.innerHTML='所选中对象的索引值为'+this.index;
divs[this.index].style.display = 'block';
}
}
}
</script>