gpt4 book ai didi

javascript - JS函数不访问所有数组图片

转载 作者:行者123 更新时间:2023-11-30 16:07:10 24 4
gpt4 key购买 nike

<分区>

我有一个图像数组,因此用户可以单击箭头来更改图像,但只能访问数组索引的前三个图像,而不是其余的。这是我的代码片段。

 <html>
<body>
<div id="debug"></div>
<div id="rightDisplay">
<div id="imgread"></div>
<img id="currentImg" alt="RoboustImage" src="http://i.imgur.com/dCS4tQk.jpg" title="click to view full scape" height="50%" width="50%" style="margin-left:20%;" />
<img id="changeImg" alt="clickandchange" src="1461670638_hand-right.png" onclick="changeImage()"></div>

</table>


<script>
var theSource;
var array;
var curImage;

function showImage(imgName) {
var curImage = document.getElementById('currentImg');
var thePath = 'http://i.imgur.com/';
var theSource = thePath + imgName;
curImage.src = theSource;
// curImage.alt = imgName;

// curImage.title = imgName;
}

function changeImage(dir) {
var img = document.getElementById('currentImg');

var imgs = ["http://i.imgur.com/dCS4tQk.jpg", "http://i.imgur.com/JKNnuSE.jpg", "http://i.imgur.com/9wHVhck.jpg", "http://i.imgur.com/dCS4tQk.jpg", "http://i.imgur.com/ZqoEU9o.jpg", "http://i.imgur.com/SpBfUZi.jpg", "http://i.imgur.com/JKNnuSE.jpg", "http://i.imgur.com/YwAmPYu.jpg", "http://i.imgur.com/T7NBjJm.jpg", "http://i.imgur.com/ujJ3g1k.jpg"];
img.src = imgs[imgs.indexOf(img.src) + (dir || 1)] || imgs[dir ? imgs.length - 1 : 0];
// var debug = document.getElementById('imgread').innerHTML=img.src;

}

</script>

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