javaScript运行时出错:无法获取未定义或null引用的属性length - 爱问答

(爱问答)

javaScript运行时出错:无法获取未定义或null引用的属性length

var current_index=0;

var timer=window.setInterval(autoChange, 5000);

var button_li=document.getElementById("button").getElementsByTagName("li");

var pic_div=document.getElementById("banner_pic").getElementsByTagName("div");

for(var i=0;i<button_li.length;i++){

 button_li[i].onmouseover=function(){ 

 if(timer){   

clearInterval(timer); 

 }  

for(var j=o;j<pic_div.length;j++){ 

  if(button_li[j]==this){  

  current_index=j;   

 button_li[j].className="current";    

pic_div[j].className="current";   

}else{   

 pic_div[j].className="pic";    

button_li[j].className="but";   }  } }

 button_li[i].onmouseout=function(){ 

 timer=setInterval(autoChange, 5000); }}

function autoChange(){ 

++current_index; 

if(current_index==button_li.length){  

current_index=0; 

for(var i=0;i<button_li.length;i++){

  if(i==current_index){   

button_li[i].className="current";   

pic_div[i].className="current"; 

 }else{

   button_li[i].className="but";

   pic_div[i].className="pic";  } }}

你首先要确定你的HTML网页中有ID为button/banner_pic等控件的

这段程序要配合HTML使用的

相关标签:java

下一篇:在电脑上淘宝网相关的宝贝链接在哪

上一篇:求素数:为什么后面会有一串奇怪的数字?

热门标签:
excel 网盘 破解 word dll
最新更新:
微软重新评估新的Outlook的使用时机 联想推出搭载联发科Helio G80芯片组的Tab M9平板 英特尔创新大赛时间确定! 微软Edge浏览器在稳定渠道中推出Workspaces功能 英伟达RTX4060TiGPU推出MaxSun动漫主题! 谷歌地图为用户提供了街景服务! GameSir 在T4 Kaleid中推出了一款出色的控制器! 微软开始在Windows 11 中测试其画图应用程序的新深色模式! LG电子推出全球首款无线OLED电视 英伟达人工智能芯片崭露头角! Steam Deck可以玩什么游戏-Steam Deck价格限时优惠 雷蛇推出CobraPro鼠标 Kindle电子阅读器可以访问谷歌商店吗 Windows10如何加入组策略 window10图片查看器怎么没有了?