Saved X
Google login
SignUp with Email
X

Clearinterval javascript

theindreshverma ( Edited  Sep 01, 12:55 am )
Login

clearinterval javascript

<!DOCTYPE html>
<html>
<body>

<button onclick="stopbgColor()">Stop color</button>

<script>
var myVar = setInterval(setbgColor, 300);
 
function setbgColor() {
  var x = document.body;
  x.style.backgroundColor = x.style.backgroundColor == "blue" ? "green" : "blue";
}
 
function stopbgColor() {
  clearInterval(myVar);
}
</script>

</body>
</html>

Sourcecode Tags

More Sourcecodes

More Sourcecodes