Welcome aboard! We are happy you are here and wish you good net-raft!
<!DOCTYPE html>
<html>
<body>
<button onclick="stopColor()">Stop Toggling</button>
<script>
var myVar = setInterval(setColor, 300);
function setColor() {
var x = document.body;
x.style.backgroundColor = x.style.backgroundColor == "yellow" ? "pink" : "yellow";
}
function stopColor() {
clearInterval(myVar);
}
</script>
</body>
</html>
The most helpful JAVASCRIPT solutions
How can I get the last day and the next day in javascript ?JAVASCRIPT Click to see more ... 5.9K 508