<p class='typewriter'>
<h1 class='typewriter-text h1' data-text='[ "Ingenuity ", "Creativity ", "Inspiration " ]'></h1>
</p>
<script>
jQuery(document).ready(function() {
typing( 0, jQuery('.typewriter-text').data('text') );
function typing( index, text ) {
var textIndex = 1;
var tmp = setInterval(function() {
if ( textIndex < text[ index ].length + 1 ) {
jQuery('.typewriter-text').text( text[ index ].substr( 0, textIndex ) );
textIndex++;
} else {
setTimeout(function() { deleting( index, text ) }, 700);
clearInterval(tmp);
}
}, 110);
}
function deleting( index, text ) {
var textIndex = text[ index ].length;
var tmp = setInterval(function() {
if ( textIndex + 1 > 0 ) {
jQuery('.typewriter-text').text( text[ index ].substr( 0, textIndex ) );
textIndex--;
} else {
index++;
if ( index == text.length ) { index = 0; }
typing( index, text );
clearInterval(tmp);
}
}, 70)
}
});
</script>