js slideshow code example
Example 1: image slideshow in jquery
<script src="jquery-3.2.1.min.js"></script>
<script src="ResponsiveSlides/responsiveslides.min.js"></script>
<script>
$(function() {
$("#slider").responsiveSlides({
auto : false,
pager : false,
nav : true,
speed : 500,
namespace : "slider-callback",
maxwidth : "550px"
});
});
</script>
Example 2: slideshow javascript
var slideshows = document.querySelectorAll('[data-component="slideshow"]');
slideshows.forEach(initSlideShow);
function initSlideShow(slideshow) {
var slides = document.querySelectorAll(`#${slideshow.id} [role="list"] .slide`);
var index = 0, time = 5000;
slides[index].classList.add('active');
setInterval( () => {
slides[index].classList.remove('active');
index++;
if (index === slides.length) index = 0;
slides[index].classList.add('active');
}, time);
}