<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input id="btn" type="button" value="关灯">
<script>
var btn = document.getElementById("btn");
btn.onclick = function(){
if(btn.value == "关灯"){
document.body.style.backgroundColor = "black";
this.value = "开灯";
}else {
document.body.style.backgroundColor = "white";
this.value = "关灯";
}
};
</script>
</body>
</html>
页面背景开关灯
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:高亮当前输入的文本框
下一篇:全选 反选
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
有趣的css - 好看的开关按钮
用css模拟实现一个好看的开关按钮动效。
css 开关按钮 动效设计 交互设计 ux/ui -
JavaScript特效——开关灯泡
准备 首先要准备两张图片,一张是灯泡亮的图片...
html 网络安全 JavaScript -
js实现开关灯效果
<!DOCTYPE html><html> <head> <meta charset="utf-8">
javascript 开关灯 一个按钮 html css -
【BZOJ 1230】 开关灯
【题目链接】 https://www.lydsy.com/JudgeOnline/problem.php?id=1230 【算法】 线段树 【代码】
#define php c++ #include 线段树