/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function teletype(id, text) { function typechar( char ) { if ( char == 'â—„' && document.getElementById(id).innerHTML >= 1) { document.getElementById(id).innerHTML = document.getElementById(id).innerHTML.substr(0, document.getElementById(id).innerHTML.length-1); } else { document.getElementById(id).innerHTML += char; } } var counter = 0; for( var i=0; i<text.length; i++ ) { setTimeout(function() { var char = text[counter]; typechar(char); counter++; }, 50 * i); } }
Comments
