JSFiddle - React, Tailwind, and code Playground
Taking from: http://snook.ca/archives/javascript/simplest-jquery-slideshow
I edited the script so that you can navigate through the photos using the previous/next buttons.
by iamacatperson
March 02, 2013
HTML
<div id="img-grp-wrap">
<div class="img-wrap">
<img src="http://www.pictures-of-cats.org/images/ragdoll-cat-small-pictures-of-cats.jpg" />
<img src="http://0.tqn.com/d/paganwiccan/1/G/T/1/-/-/BlackCat.jpg" />
<img src="http://2.bp.blogspot.com/-H_iTYn3QQOk/Tfp5aK2vi5I/AAAAAAAAABM/QM45bNOM4HY/s1600/cat-claw.jpg" />
<img src="http://www.pictures-of-cats.org/images/Pixiebob-cat-list-of-cat-breeds-pictures-of-cats.jpg" />
</div>
<img src="http://annhowardesign.com/images/arrowright.jpg" class="next" alt="Next"/>
<img src="http://annhowardesign.com/images/arrowleft.jpg" class="prev" alt="Previous"/>
</div>
CSS
#img-grp-wrap {
position: relative;
width: 180px;
height: 180px;
margin: 100px auto;
}
.img-wrap {
position: relative;
border: 1px solid #CCC;
width: 180px;
height: 180px;
}
.img-wrap img {
position: absolute;
top: 0;
left: 0;
-moz-box-shadow: 1px 1px 4px #CCC;
padding: 10px;
}
.next, .prev {
position: absolute;
cursor: pointer;
top: 70px;
}
.next {
right: -40px;
}
.prev {
left: -40px;
}
JavaScript
var rotate;
var imgFirst = $('#img-grp-wrap .img-wrap img:first-child');
$('#img-grp-wrap .img-wrap img:gt(0)').hide();
function slideShow() {
$('#img-grp-wrap .img-wrap img:first-child').fadeOut().next('img').fadeIn().end().appendTo('.img-wrap');
}
var rotate = setInterval(function() {
slideShow();
}, 4000);
$('#img-grp-wrap .prev, #img-grp-wrap .next').hover(function() {
clearInterval(rotate);
}, function() {
var rotate = setInterval(function() {
slideShow();
}, 4000);
});
$('#img-grp-wrap .next').click(function() {
$('#img-grp-wrap .img-wrap img:first-child').stop().fadeOut().next().fadeIn().end().appendTo('.img-wrap');
});
$('#img-grp-wrap .prev').click(function() {
$('#img-grp-wrap .img-wrap img:first-child').stop().fadeOut();
$('#img-grp-wrap .img-wrap img:last-child').prependTo('.img-wrap').fadeOut();
$('#img-grp-wrap .img-wrap img:first-child').fadeIn();
});