Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

display letter in html element letter by letter

document.addEventListener('DOMContentLoaded', function() {

    showText("#msg", "Hello, World!", 0, 100);

});

let showText = function (target, message, index, interval) {
    if (index < message.length) {
        document.querySelector(target).innerHTML =
            document.querySelector(target).innerHTML + message[index++];
        setTimeout(function () { showText(target, message, index, interval); }, interval);
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #display #letter #html #element #letter #letter
ADD COMMENT
Topic
Name
1+8 =