以下代码执行我想要的操作,一次只显示1张图片。 但是当我单击NEXT或PREVIOUS按钮时图像 不会改变。我已经搜索了答案。 作为这类代码的新手,我迷失了。
<input type="button" id="prev" value="Previous" onClick="previous()">
<input type="button" id="prev" value="Next" onClick="next()">
<script type="text/javascript">
function previous() {
if (which <= 0) {
which = photos.length - 1;
} else {
which--;
}
}
document.images.photoslider.src=photos[which];
function next(){
if (which > $picture.length -1){
which = 0;
} else {
which = which + 1;
}
}
document.images.photoslider.src=$picture[which];
</script>