【www.bbyears.com--网页配色】
使用JavaScript实现开关效果也是很多人会遇到的操作,这次文章就给大家简单的介绍下方法,感兴趣的一起来看看。
开关灯 <script type="text/javascript"> var oBody = document.getElementById("bodyEle"); oBody.onclick = function () { var bg = this.style.backgroundColor; switch (bg) { case "white": this.style.backgroundColor = "red"; break; case "red": this.style.backgroundColor = "black"; break; default: this.style.backgroundColor = "white"; } } </script>