我有一个网页,其中设置了一个链接来更改页面的背景颜色、链接的颜色和链接文本。这是我的代码:
<html>
<head>
<title>Title</title>
<script type="text/javascript">
function Lights() {
document.body.style.backgroundColor='#000000';
document.getElementById("on").innerHTML="Turn on the lights";
document.getElementById("on").style.color="#00ffff";
}
</script>
</head>
<body style="font-size:200px; text-align:center;">
<a href="javascript:void(0)" id="on" onclick="Lights()">Turn off the lights</a>
</body>
</html>
我想知道当再次单击链接时如何设置 JavaScript 以反转这些语句,使页面返回白色背景,文本返回“关闭灯”,链接返回深蓝色.
谢谢