Text growing and shrinking

 

<!DOCTYPE html>

<html>

<body>

    <div id="h"></div>

    <script>

        var v = 0, f = 1, t = "TEXT-GROWING", color;


        function a() {

            if (f == 1) {

                v += 5;

                color = "red";

            } else {

                v -= 5;

                color = "blue";

            }


            document.getElementById("h").innerHTML = 

                "<h1 style='font-size:" + v + "px;color:" + color + ";'><b>" + t + "</b></h1>";


            if (v >= 50) {

                f = 0;

                t = "TEXT-SHRINKING";

            }

            if (v <= 5) {

                f = 1;

                t = "TEXT-GROWING";

            }


            c();

        }


        function c() {

            setTimeout(a, 300);

        }


        c();

    </script> 

</body> 

</html>

Comments

Popular posts from this blog

Web

Lab 1 ai