In this applet, you need to set the name of the images folder to sequential, 1, 2, 3 ......
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Var imgnumb = 1;
Function imgfor (){
Imgnumb ++;
Document. getElementById ('img1'). setAttribute ('src', 'images/'+ imgnumb + '.jpg ');
If (imgnumb = 5) {// 5 images in total
Imgnumb = 0;
}
}
Var clearid;
Function clearfun (){
ClearInterval (clearid );
}
Clearid = setInterval (imgfor, 500 );
</Script>
</Head>
<Body>
<Input type = "button" value = "end execution" onclick = "clearfun ();"/>
</Body>
Var imgnumb = 1;
Function imgfor (){
Imgnumb ++;
Document. getElementById ('img1'). setAttribute ('src', 'images/'+ imgnumb + '.jpg ');
If (imgnumb = 5 ){
Imgnumb = 0;
}
}
Var clearid;
Function clearfun (){
ClearInterval (clearid );
}
Clearid = setInterval (imgfor, 500 );
</Script>
</Head>
<Body>
<Input type = "button" value = "end execution" onclick = "clearfun ();"/>
</Body>