<body>
<button id="btn">开</button>
<script>
var btnE = document.getElementById('btn'),
text;
btnE.addEventListener('click',function(){
text = btnE.innerText;
btnE.innerText = text === "开" ? "关":"开";
text === "开" ? document.body.style.backgroundColor = "red":document.body.style.backgroundColor = "white";
});
</script>
</body>