Something like this will work for you.
Jsfiddle Demo
HTML (reload div for look: P)
<div id="page_title"></div>
<br>
<span id="text-reload">Reload</span>
Js
$.fn.loadText = function( textArray, interval ) {
return this.each( function() {
var obj = $(this);
obj.fadeOut( 'slow', function() {
var elem = textArray[0];
obj.empty().html( elem );
textArray.shift();
textArray.push(elem);
obj.fadeIn( 'fast' );
});
timeOut = setTimeout( function(){ obj.loadText( textArray, interval )}, interval );
$("#text-reload").click( function(){
if( !obj.is(':animated') ) { clearTimeout( timeOut ); obj.loadText( textArray, interval );}
});
});
};
$(document).ready(function() {
var helloArray = ["Hi I am a title", "Hi I am another title", "I am also a title", "more", "and more", "and even more", "aloha", "see ya!"];
$('#page_title').loadText( helloArray, 5000 );
document.title = $('#page_title').text();
});
source
share