JS练习开关灯


<style type="text/css">
html,body{
margin: 0;
padding: 0;;
cursor: pointer;
width: 100%;
height: 100%;
}
</style>


<body id="ids">
<script type="text/javascript">
console.log("开始");
var did =document.getElementById("ids");
did.onclick = function(){
console.log("sad");
var bg =this.style.backgroundColor;

switch (bg){
case "white" :
this.style.backgroundColor = "blue";
break;
case "blue" :
this.style.backgroundColor = "red";
break;
case "red" :
this.style.backgroundColor ="yellow";
break;
case "yellow" :
this.style.backgroundColor = "black";
break;
default: this.style.backgroundColor ="white";
}
}
</script>
</body>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM