JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css">
<ul id="text">
<li id="textBody">Suffering is not a result of physical pain alone. It can be compounded by changes in one's life, and changes in the self. <em>We understand, and we can help.</em></li>
<li id="textFamily">Aggressive assessment of physical symptoms & pain in the body are key to support <em>the best possible quality of life</em>.</li>
<li id="textFunction">Chronic pain & illness may affect your role in your family. We work with you and your family as you confront those changes.</li>
<li id="textPsyche">Chronic pain and illness make even everyday activities challenging. We will help you maintain independence and physical function.</li>
<li id="textSuffering">Changes in the physical body mean changes in the self. We will provide support as you navigate those changes in the psyche.</li>
</ul>
<ul id="vivid_buttons">
<li><a href="#" id="buttonBody">BODY</a></li>
<li><a href="#" id="buttonFamily" class="active">FAMILY</a></li>
<li><a href="#" id="buttonFunction">FUNCTION</a></li>
<li><a href="#" id="buttonPsyche">PSYCHE</a></li>
<li><a href="#" id="buttonSuffering">SUFFERING</a></li>
</ul>
CSS
ul#text { position: relative; margin-bottom: 40px; height: 40px; }
ul#text li { position: absolute; display: none; }
.active { font-weight: bold; }
JavaScript
$(document).ready(function () {
// cache the LI elements
var $lis = $("#text > li");
var $aLis = $("#vivid_buttons > li");
function fadeAndMove( currentIndex ) {
var nextIndex = (currentIndex + 1) % 5;
var nextLi = $lis.eq( nextIndex );
nextLi.fadeIn(1000, function () {
$aLis.eq( currentIndex ).children('a').removeClass("active");
$aLis.eq( nextIndex ).children('a').addClass("active");
setTimeout(function () {
nextLi.fadeOut(1000, function() {
// Call fadeAndMove() passing nextIndex as the new currentIndex
fadeAndMove( nextIndex );
});
}, 4000);
});
}
// Get it started on index 0
fadeAndMove( 0 );
});