<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <input type="button" value="关灯" id="btn"> <script src="common.js"></script> <whether to turn on the lights turn off the lights false true state status lights//>Script var isOpen = true; my$('btn').onclick = function () { if (isOpen) { document.body.style.backgroundColor = 'black'; this.value = '开灯'; isOpen = false; } else { document.body.style.backgroundColor = 'white'; this.value = '关灯'; isOpen = true; } } </script> </body> </html>