Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript slideshow cycles fine twice, then bugs out
    primarykey
    data
    text
    <p>I followed a tutorial to create a simple javascript slideshow but I am having a strange bug... The first 2 cycles work perfectly, but once the counter resets the slideshow begins showing the previous slide quickly then trying to fade in the correct slide. Any idea what is causing this?</p> <p>I have 3 images (named <code>Image1.png</code>, <code>Image2.png</code>, and <code>Image3.png</code>) in a folder for my simple slideshow and 3 divs set up like this:</p> <pre><code> &lt;div id="SlideshowFeature"&gt; &lt;div id="counter"&gt; 3 &lt;/div&gt; &lt;div class="behind"&gt; &lt;img src="SlideShow/image1.png" alt="IMAGE" /&gt; &lt;/div&gt; &lt;div class="infront"&gt; &lt;img src="SlideShow/image1.png" alt="IMAGE" /&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>My javascript looks like this </p> <pre><code>var nextImage; var imagesInShow; var currentImage; var currentSrc var nextSrc function changeImage() { imagesInShow = "3"; currentImage = $("#counter").html(); currentImage = parseInt(currentImage); if (currentImage == imagesInShow) { nextImage = 1; } else { nextImage = currentImage + 1; } currentSrc = $(".infront img").attr("src"); nextSrc = "SlideShow/image" + nextImage + ".png"; $(".behind img").attr("src", currentSrc); $(".infront").css("display", "none"); $(".infront img").attr("src", nextSrc); $(".infront").fadeIn(1000); $("#counter").html(nextImage); setTimeout('changeImage()', 5000); } $(document).ready(function () { changeImage(); }); </code></pre> <p><strong>EDIT:</strong></p> <p>Also here is my CSS</p> <pre><code>#SlideshowFeature { text-align:center; margin: 0 auto; width:800px; background: #02183B; height:300px; float: left; overflow:hidden; display:inline; } #SlideshowFeature div { width: 800px; height:300px; position:absolute; } #counter { display:none; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload