gpt4 book ai didi

javascript函数调用不循环图像数组

转载 作者:行者123 更新时间:2023-11-28 08:18:52 24 4
gpt4 key购买 nike

创建了这个简单的图像数组库

javascript 函数调用不循环图像数组

var imagecount=0;
var imageArray = ["images/1.jpg","images/2.jpg","images/3.jpg","images/4.jpg"];
var allimages=imageArray.length-1;


function next()
{
imagecount++;
if(imagecount>allimages) {
imagecount=0;
}
document.getElementById("slideshow").src=imageArray[imagecount];
}

function prev()
{
imagecount--;
if(imagecount<0) {
imagecount=allimages;
}
document.getElementById("slideshow").src=imageArray[imagecount];
}

document.getElementById("next").onclick=next;

document.getElementById("previous").onclick=prev;

当我在 javascript 本身中调用该函数时,图像库不会循环

最佳答案

检查这个fiddle 出来,这正是你的代码,它对我有用..

这可能是浏览器特定的问题..

关于javascript函数调用不循环图像数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23247970/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com