简体   繁体   中英

JavaScript image slider not working

It just stays on a single image and doesn't advance the slide. I've checked other posts that have the same code and I can't find any differences. I need it all to be a single html as I'm using this for Wordpress.

Here is my html code:

<style>
#slideshow { 
    position: relative; 
    width: 240px; 
    height: 240px; 
    padding: 10px; 
    box-shadow: 0 0 20px rgba(0,0,0,0.4); 
}
#slideshow > div {  
    position: absolute;
    top: 10px; 
    left: 10px; 
    right: 10px; 
    bottom: 10px; 
}
</style>

<div id="slideshow">
<div>
<a href="http://www.slideshare.net/billbayer/sell-or-die-the-sales-imperative">
<img src="http://www.billbayer.net/wp-content/uploads/2013/08/sell.png" width="100%" height="100%">
</a>
</div>
<div>
<a href="http://www.slideshare.net/billbayer/bill-bayer-2013-economic-forecast">
<img src="http://www.billbayer.net/wp-content/uploads/2013/08/economic.png" width="100%" height="100%">
</a>
</div>
<div>
<a href="http://www.slideshare.net/billbayer/lgr-fatal-illusions-april-2009">
<img src="http://www.billbayer.net/wp-content/uploads/2013/08/fatal.png" width="100%" height="100%">
</a>
</div>
<div>
<a href="http://www.slideshare.net/billbayer/mastering-change-march-21-2013">
<img src="http://www.billbayer.net/wp-content/uploads/2013/08/mastering.png" width="100%" height="100%">
</a>
</div>
</div>

<script>
$("#slideshow > div:gt(0)").hide();
setInterval(function() { 
  $('#slideshow > div:first')
    .fadeOut(1000)
    .next()
    .fadeIn(1000)
    .end()
    .appendTo('#slideshow');
},  3000);
</script>

http://jsfiddle.net/Rouse94/j6PSA/

You have not added javascript code in your fiddle.

Your code works correctly.

Updated fiddle here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM