SetInterval (' ChangeImg () ', 1500); }
Var I=1;
The function ChangeImg () {I +=1; Document. The getElementById (" img "). The SRC='https://bbs.csdn.net/topics/image/img' + I + 'JPG'; If (I==7) {I=0; }}
</script>
Var index=0;
The function next () {document. GetElementById (" img "). src=https://bbs.csdn.net/topics/imgArr [index];
Index++;
If (index==imgArr. Length) {index=0; }}
The function back () {document. GetElementById (" img "). The SRC=https://bbs.csdn.net/topics/imgArr [index];
The index -;
If (index<0 {index=imgArr. Length - 1; }}
</script>
CodePudding user response:
Var imgArr=[" images/img1. JPG ", "image/img2. JPG", "image/img3. JPG", "image/img4. JPG", "image/img5. JPG", "image/img6. JPG", "image/img7. JPG"].
Var index=0;
The function next () {
Index++;
If (index==imgArr. Length) {
The index=0;
}
Document. The getElementById (" img "). The SRC=https://bbs.csdn.net/topics/imgArr [index];
}
The function back () {
index--;
If (index & lt; 0 {
index=imgArr.length - 1;
}
Document. The getElementById (" img "). The SRC=https://bbs.csdn.net/topics/imgArr [index];
}
</script>
Document. The getElementById (" img "). The SRC=https://bbs.csdn.net/topics/imgArr [index]; You should be placed behind the index after the change, and you define an array has a problem, I can't see two commas together
CodePudding user response:
With front frame,