Display Alphabets by setInterval() Function | SJB -->

This website uses cookies to ensure you get the best experience. More info...

Pages

Display Alphabets by setInterval() Function

This page is built based on one and half year old tiny person's idea. My son AARON loves reading alphabets. I thought I could show alphabets one by one with a time interval and of course with bigger fonts. I used setInterval() function to write a little script to make him happy.



Below is the little script that is used to display alphabets_

1
2
3
4
5
6
7
8
9
10
11
12
13
var alphBtID;
var alphBtsCount = 0;
var alphBts = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
function alphBtsStart() {
    if (alphBtID) {
        clearInterval(alphBtID);
    }
    alphBtID = setInterval(function () {
        document.getElementById("alphBtsPanel").innerHTML = alphBts.charAt(alphBtsCount);
        alphBtsCount++;
    }, 2500);
};

No comments:

Post a Comment