SetTimeout() and ClearTimeout()

 SetTimeout() and ClearTimeout()


 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Testing Javsript</title>
<style>

    #box{
      width100px;
      height : 120px;
      background-colorrgb(2474121);  
    }

</style>

</head>
<body>
    
<div id="box"> </div><br>
<button onclick="valid()"> CLICK ME TO STOP ANIMATION</button>
<script>

var calc=0;

    var b = setTimeout(animate1500);

    function animate(){
        var a = document.getElementById("box");
        a.style.width = "500px";
    }

    function valid()
    {
        clearInterval(b);
    }
    
</script>

</body>
</html>

 

 

 

Comments

Popular posts from this blog