Auto Text using HTML and JS

 Auto Text using HTML and JS


HTML CODE

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div id="text">
        this is text
    </div>
    <script src="script.js"></script>
</body>
</html>

JAVASCRIPT

const text=document.getElementById("text").innerText;

let i=0;
function autoText(){
    document.getElementById("text").innerText=text.slice(0,i);
    i++;
    if(i>text.length){
        i=0;
    }
}

setInterval(autoText,100);

Comments

Popular posts from this blog

How to make simple bill maker by using python tkinter

Make a GST Calculator using HTML and JavaScript

Write a program to find the sum of 1/2+4/3+5/6+8/7+9/10 using loop in java