标签:element func elements nbsp ack oct 变换 UNC out
原生JavaScript定时器实现背景颜色交替变换
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <title>Title</title> <style> div{ width: 200px; height: 200px; background-color: #d58512; } .bgc-1{ background-color: hotpink; } </style> </head> <body> <div class="bgc-1"></div> <script> let divEle = document.getElementsByTagName("div")[0]; setInterval(function () { divEle.classList.remove("bgc-1");},2000); // 设置1秒后执行func函数(只调用一次) setTimeout(func,1000); function func() { setInterval(function () { divEle.classList.add("bgc-1")},2000) } </script> </body> </html>
标签:element func elements nbsp ack oct 变换 UNC out
原文地址:https://www.cnblogs.com/believepd/p/9839534.html