junyi-bk

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>

<button onclick="stopColor()">停止切换</button>

<script>
var myVar = setInterval(function(){ setColor() }, 50);

function setColor() {
var x = document.body;
x.style.backgroundColor = x.style.backgroundColor == "yellow" ? "pink" : "yellow";
}

function stopColor() {
clearInterval(myVar);
}
</script>

</body>
</html>

分类:

技术点:

相关文章:

  • 2021-12-19
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
  • 2021-12-19
猜你喜欢
  • 2021-12-19
  • 2021-11-29
  • 2021-10-19
  • 2021-12-19
  • 2022-12-23
  • 2021-05-03
  • 2021-12-19
相关资源
相似解决方案