How to convert THIS image slideshow --> https://jsfiddle.net/ukrkw4nb/19/ into TEXT slideshow so that list itemst (li's) show in loop the following 3 words: 1.Users, 2.Leads 3. Sales This is my attempt https://jsfiddle.net/ukrkw4nb/90/
Code below:
$(function() {
var slides = $('.slideShow>li');
var slideCount = 0;
var totalSlides = slides.length;
var slideCache = [];
(function preloader() {
if (slideCount < totalSlides){
slideCache[slideCount] = new Image();
slideCache[slideCount].src = slides.eq(slideCount).find('img').attr('src');
slideCache[slideCount].onload = function() {
slideCount++;
preloader();
}
} else {
// Run the slideshow
slideCount = 0;
SlideShow();
}
}());
function SlideShow() {
slides.eq(slideCount).fadeIn(1000).delay(2000).fadeOut(1000, function() {
slideCount < totalSlides - 1 ? slideCount ++ : slideCount = 0;
SlideShow();
});
}
});
I think I have it working the way you'd like.
I edited this a bit: my grasp of jQuery could be better and it threw me: the preloader function was to deal with using images, and is unnecessary for a text slideshow. Just write the html you want, remove the preloader function, and then call the SlideShow function.
$(function() {
var slides = $('.slideShow>li');
var slideCount = 0;
var totalSlides = slides.length;
var slideCache = [];
function SlideShow() {
slides.eq(slideCount).fadeIn(1000).delay(2000).fadeOut(1000, function() {
slideCount < totalSlides - 1 ? slideCount ++ : slideCount = 0;
SlideShow();
});
}
SlideShow();
});
* {
margin:0;
padding:0;
}
li {
display:none;
}
li:first-of-type {
display:block;
}
div {
position:absolute;
width:200px;
height:200px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="slideShowContainer">
<ul class="slideShow">
<li>Users</li>
<li>Leads</li>
<li>Sales</li>
</ul>
</div>