gpt4 book ai didi

javascript - 为什么这个幻灯片代码不起作用?

转载 作者:行者123 更新时间:2023-12-02 19:06:57 24 4
gpt4 key购买 nike

<img id="slideshow" src="4.png" alt="image" width="264" height="264"/>
<script>
source=["1.jpg", "2.JPG", "3.JPG"];
for (var i=0; i<source.length; i++)
{
document.getElementById("slideshow").src = source[i];
}
</script>

不太明白为什么这不起作用,我意识到这会停止在图像上,我认为至少是这样,哈哈,但它不显示任何图像。

任何帮助都会非常感谢。

            <img id="slideshow" src="4.png" alt="image" width="264" height="264"/>
<script>
source=["1.jpg", "2.JPG", "3.JPG"];
var i=0;
var c=0;
while (i<=0)
{
if (c<source.length)
document.getElementById("slideshow").src = source[c];
c++;
else
c=0;
}
</script>

有什么想法如何让它在每个源上停止然后重复?

最佳答案

您的代码中有一个拼写错误:

for (var i=0; i<source.lenth; i++)
~~~~~
^

它应该是长度而不是长度

关于javascript - 为什么这个幻灯片代码不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14226104/

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