Skip to content

Instantly share code, notes, and snippets.

@martynchamberlin
Last active December 27, 2015 07:09
Show Gist options
  • Save martynchamberlin/7287246 to your computer and use it in GitHub Desktop.
Save martynchamberlin/7287246 to your computer and use it in GitHub Desktop.
This is the most drop-dead simple jQuery slideshow you could possibly have. Nothing fancy at all, but mind-boggling get-out-of-the-way simple. Actually using it for a client project.
<div id="slider">
<img>
<input type="hidden" value="/wp-content/themes/geek/images/slide1.png">
<input type="hidden" value="/wp-content/themes/geek/images/slide2.png">
<input type="hidden" value="/wp-content/themes/geek/images/slide3.png">
<input type="hidden" value="/wp-content/themes/geek/images/slide4.png">
</div>
jQuery(document).ready(function( $ )
{
var i = 0;
var url = $('#slider input');
function slide()
{
$('#slider img').attr('src', $(url[i]).val() );
i >= $('#slider input').length - 1 ? i = 0 : i++;
}
setInterval(slide, 7000);
slide();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment