JSFiddle - React, Tailwind, and code Playground
by Elak
HTML
<ul id="items">
<li class="show">
<a href="#">
<div id="caption">
<h5>Featured Counselor</h5>
<h3>Courtney Humphrey</h3>
<h4>Registered Dietician</h4>
</div><!-- End #caption -->
<div id="featured-counselor">
<img src="img/featured_counselor_placeholder.jpg" />
</div><!-- End #featured-counselor -->
</a>
</li>
<li>
<a href="#">
<div id="caption">
<h5>Featured Counselor</h5>
<h3>Test Two Title</h3>
<h4>Registered Dietician</h4>
</div><!-- End #caption -->
<div id="featured-counselor">
<img src="img/featured_counselor_placeholder.jpg" />
</div><!-- End #featured-counselor -->
</a>
</li>
CSS
article[role=main] aside li {/*Set up the basic stying & hide them all*/
list-style: none;
margin: 0px;
padding: 0px;
display: none;
}
article[role=main] aside li.show { /*Only show one at a time*/
display: block;
}
JavaScript
featuredCounselorCarousel(); //Call the function that runs the show
function featuredCounselorCarousel() {
showCurrentCounselor(); //Show the Counselor First
setTimeout(function() { //Add a timer (Show for 5 seconds)
hideCurrentCounselor() //After 5 seconds, hide the current counselor
}, 5000)
}// End featuredCounselorCarousel
function showCurrentCounselor() { //This is the Function that shows the Counselor
$('article[role=main] aside ul li.show #featured-counselor').delay( 100 ).animate({"left": "0px"}, 900, 'easeInOutQuint');//Slide out
$('article[role=main] aside ul li.show #caption').delay( 1000 ).fadeIn(400);//Display the Caption
}// End showCurrentCounselor
function hideCurrentCounselor() { //This is the Function that hides the Counselor
$('article[role=main] aside ul li.show #featured-counselor').delay( 100 ).animate({"left": "-230px"}, 900, 'easeInOutQuint');//Slide Back In
$('article[role=main] aside ul li.show #caption').delay( 500 ).fadeOut(400);//Remove the Caption
}// End hideCurrentCounselor