Skip to content

Instantly share code, notes, and snippets.

@fxrobin
Created April 6, 2018 08:46
Show Gist options
  • Select an option

  • Save fxrobin/aebdfbe16e319504c0c14923aa491c58 to your computer and use it in GitHub Desktop.

Select an option

Save fxrobin/aebdfbe16e319504c0c14923aa491c58 to your computer and use it in GitHub Desktop.
Displays a String like Terminator
var text = $('.typewriter').text();
var length = text.length;
var timeOut;
var character = 0;
(function typeWriter() {
timeOut = setTimeout(function() {
character++;
var type = text.substring(0, character);
type = type + "\u2588";
$('.typewriter').text(type);
typeWriter();
if (character == length) {
clearTimeout(timeOut);
}
}, 30);
}());
---- USE :
<p class="typewriter">Nullam id dolor id nibh ultricies vehicula ut id elit.
Maecenas faucibus mollis interdum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi leo risus,
porta ac consectetur ac, vestibulum at eros. Cras justo odio, dapibus ac facilisis in, egestas</p>
---- NEED : JQUERY 1.10.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment