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{
width: 100px;
height : 120px;
background-color: rgb(24, 74, 121);
}
</style>
</head>
<body>
<div id="box"> </div><br>
<button onclick="valid()"> CLICK ME TO STOP ANIMATION</button>
<script>
var calc=0;
var b = setTimeout(animate, 1500);
function animate(){
var a = document.getElementById("box");
a.style.width = "500px";
}
function valid()
{
clearInterval(b);
}
</script>
</body>
</html>
Comments
Post a Comment
I WOULD APPRECIATE IF YOU LEAVE A COMMENT OR YOUR FEEDBACK HERE !!!