java定时器报错,定时器设置报错
麻煩老師看一下,報錯原因:
輪播.html:136?Uncaught?TypeError:?Cannot?set?property?'onmouseover'?of?null
at?slideImg?(輪播.html:136)
at?輪播.html:153
slideImg????@????輪播.html:136????(anonymous)????@????輪播.html:153
找了一下沒有找到解決辦法。
html>
綜合實例*{
margin:0;
padding:0;
}
ul{
list-style:?none;
}
body{
font-family:"微軟雅黑";
color:#14191e;
}
.main{
width:1200px;
height:460px;
margin:30px?auto;
overflow:hidden;
position:relative;
}
.banner{
width:1200px;
height:460px;
overflow:hidden;
position:relative;
}
.banner-slide{
width:1200px;
height:460px;
background-repeat:?no-repeat;
position:absolute;
display:none;
}
.slide1{
background-image:url("C:/huaXiaXia/Sublime%20Text%203/教輔/實現輪播教輔/JavaScript實現輪播特效(代碼)/img/bg1.jpg");
}
.slide2{
background-image:url("C:/huaXiaXia/Sublime%20Text%203/教輔/實現輪播教輔/JavaScript實現輪播特效(代碼)/img/bg2.jpg");
}
.slide3{
background-image:url("C:/huaXiaXia/Sublime%20Text%203/教輔/實現輪播教輔/JavaScript實現輪播特效(代碼)/img/bg3.jpg");
}
.slide-active{
display:block;
}
.button{
position:absolute;
width:40px;
height:80px;
left:244px;
top:50%;
margin-top:-40px;
background-color:green;
background:?url("C:/huaXiaXia/Sublime%20Text%203/教輔/實現輪播教輔/JavaScript實現輪播特效(代碼)/img/arrow.png")?no-repeat?center?center;
}
.pre{
transform:rotate(180deg);
}
.next{
left:auto;
right:0;
}
.button:hover{
background-color:#333;
opacity:0.5;
filter:alpha(opacity:50);
}
.dots{
position:absolute;
right:20px;
bottom:24px;
text-align:right;
}
.dots?span{
display:inline-block;
width:12px;
height:12px;
border-radius:50%;
/*rbga,a為透明度*/
background:rgba(7,17,27,0.4);
/*陰影,水平?垂直?距離?模糊程度?顏色?內陰影*/
box-shadow:?0?0?0?2px?rgba(255,255,255,0.8)?inset;
margin-left:8px;
line-height:12px;
cursor:pointer;
}
.dots?span.active{
box-shadow:?0?0?0?2px?rgba(7,17,27,0.4)?inset;
background:#fff;
}
//封裝一個getElementById()的方法
function?byId(id){
return?typeof(id)?===?"string"?document.getElementById(id):id;
}
var?index=0,
timer=null,
pics=byId("banner").getElementsByTagName("div"),
len=pics.length;
function?slideImg(){
var?main=byId("main");
main.onmouseover?=?function(){
//滑過清除定時器
}
main.onmouseout?=?function(){
//setTimeout超時定時器?setInterval界限調用
timer=setInterval(function(){
index++;
if(index>=len){
index?=?0;
}
//切換圖片
//?changeImg();
console.log(index);
},2000);
}
}
slideImg();
//切換圖片
//?function?changeImg(){
//??//遍歷banner下的所有div將其隱藏
//??for(var?i=0;i
//???pics[i].style.display="none";
//??}
//??//根據index所有找到div將其顯示出來
//??pics[index].style.display='block';
//?}
總結
以上是生活随笔為你收集整理的java定时器报错,定时器设置报错的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信怎么看完整银行卡号
- 下一篇: java hashmap实例,关于jav