I've written some js to the word displaying in #changingword
loops through several different words. It mostly works however when it first loads it skips through the second word so it goes from 'design' straight to 'e-commerce solutions', without showing the 'development'. After the first loop it works correctly. My code is below.
The html:
<div class="col-lg-8 col-md-8 col-sm-8 col-xs-12">
<h1>Creative Development</h1>
<h2 id="changingword">Design</h2>
</div>
The JS:
<script>
(function(){
var words = [
'Development',
'E-commerce Solutions',
'Optimisation',
'Support',
'Design'
], i = 0;
setInterval(function(){
$('#changingword').fadeOut(function(){
$(this).html(words[i=(i+1)%words.length]).fadeIn("slow");
});
}, 1500);
})();
</script>
Any ideas why this is happening?