How to type automatically through JavaScript?

 Description:- Through this code your text will going to type automatically on the browser screen. If you guys want to change the text according to your choice so you can edit the text, just go to var string and change the text and add your own text. 

<!DOCTYPE html>
<head>
<title>self typing</title>
<style>
#text{background-color:rgba(51,51,51,1); width:500px; height:250px; color:rgba(255,255,255,1); font-size:20px; padding:20px;}
</style>
</head>
<body>
<div id="text"></div>
</body>
</html>
<script>
var string="Hi welcome to the Webtechball, where you will get the code of amazing examples on the topic of php, html, css, javascript, jQuery and Bootstrap";

var ab= string.split("");
var timer;

function frame()
{
    if(ab.length>0)
    {
        document.getElementById("text").innerHTML+=ab.shift();
    }    
    else
    {
        clearTimeout(timer);
    }
    timer=setTimeout('frame()',100);
}
frame();
</script>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s