Home > front end >  Please the teacher for help, the clear setInterval and clearInterval!!!
Please the teacher for help, the clear setInterval and clearInterval!!!

Time:09-28

Please the teacher for help, use the mouse to move into and out of the event, after removing the setInterval (2000) time, and then continue to setInterval (time, 2000), image switching faster and faster!



Var lis=document. GetElementsByName (" tx ")
Var index=0

For (I=0; I & lt; The lis. Length; I++) {
The lis [I]. Style. The display="none";
}
The lis [0]. Style. The display="block"

Var time=function () {
For (I=0; I & lt; The lis. Length; I++) {
The lis [I]. Style. The display="none";
}
The lis [index]. Style. The display="block"
If (index & lt; The lis. The length - 1) {
Index++
} else {
The index=0
}
The console. The log (index)
}

Var mytimer=setInterval (time, 2000)

Var box=document. GetElementById (" box ");
Var left=document. GetElementById (" left ");
Var right=document. GetElementById (" right ");

Box. onm ouseover=function () {
Left. Style. The display="block";
Right. Style. The display="block";
ClearInterval (mytimer);

}
Box. onm ouseout=function () {
Left. Style. The display="none";
Right. Style. The display="none";
Var mytimer=setInterval (time, 2000);
}

CodePudding user response:

Box. onm ouseout=function () {
Left. Style. The display="none";
Right. Style. The display="none";
var mytimer=setInterval (time, 2000);//remove the var
}

CodePudding user response:

Thank you teacher, I see the
  • Related