目前我有一张图片,但稍后会超过1张
此代码显示第一张图像,后来显示空白但我希望它在有单张图像时再次显示第一张图像。
但是当多个图像
<div class="slideshow-cont">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div class="mySlides fade">
<asp:ImageButton ID="Image1" runat="server" CssClass="img img-responsive" ImageUrl='<%# Eval("Offer_image") %>' Width="100%" />
</div>
</ItemTemplate>
</asp:Repeater>
</div>
<br />
<script language="jscript" type="text/jscript">
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) { slideIndex = 1 }
slides[slideIndex - 1].style.display = "block";
setTimeout(showSlides, 2000); // Change image every 2 seconds
}
</script>