欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript實(shí)現(xiàn)開關(guān)等效果

 更新時間:2017年09月08日 11:42:13   作者:ruirui_1996  
本文給大家分享一段簡單的代碼基于js實(shí)現(xiàn)開關(guān)燈效果,代碼簡單易懂,非常不錯,具有參考借鑒價值,需要的朋友參考下吧

廢話不多說了,直接給大家貼代碼了,具體代碼如下所示:

<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
 <title>開關(guān)燈</title>
 <style type="text/css">
  html, body {
   margin: 0px;
   padding: 0px;
   width: 100%;
   height: 100%;
   cursor: pointer;
   background-color: white;
  }
 </style>
</head>
<body id="bodyEle">
<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>
</body>
</html>

總結(jié)

以上所述是小編給大家介紹的JavaScript實(shí)現(xiàn)開關(guān)等效果,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評論