点击开关灯文字,实现转换
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>开关灯案例</title>
<style>
#light{
width: 100px;
height: 100px;
margin: 200px 0 0 100px;
background-color: yellow;
border-radius: 50px;
}
#switch{
width: 50px;
height: 30px;
margin-left: 125px;
background-color: orange;
line-height: 30px;
text-align: center;
}
.post{
width: 10px;
height: 200px;
background-color: slategray;
margin-left: 145px;
}
</style>
<script>
window.onload = function () {
document.getElementById("switch").onclick = function () {
if (this.innerText == '关灯') {
doc