I would like to know how to iterate over the h1 element, and get each word to fade in one after the other.
I got it done, but the code is not dry. Can someone please show and explain how to do this with a loop?
$('document').ready(function() {
$('#H').fadeIn(3000).removeClass("hidden").addClass("hColor1");
$('#e').fadeIn(5000).removeClass("hidden").addClass("hColor2");
$('#l').fadeIn(6000).removeClass("hidden").addClass("hColor3");
$('#secondL').fadeIn(7000).removeClass("hidden").addClass("hColor4");
$('#o').fadeIn(7300).removeClass("hidden").addClass("hColor5");
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="container">
<h1 class="hidden"><span id="H">Hello</span> <span id="e">everyone</span> <span id="l">lets</span> <span id="secondL">learn</span> <span id="o">javascript</span></h1>
</div>