我正在制作一个网站,我希望打开和关闭深色模式。我一直在寻找如何反转函数,但由于我很擅长 JavaScript,所以无法设置函数来反转它。所以我想在这里扭转这个局面:
<label class="switch">
<input id="input" onclick="changeColor(); changeColo(); changeCol(); changeCo(); changeC();" type="checkbox">
<span class="slider round"></span>
</label>
var colors = ["#2D2D2D"];
var colorIndex = 0;
function changeColor() {
var col = document.getElementById("body");
if( colorIndex >= colors.length ) {
colorIndex = 0;
}
col.style.backgroundColor = colors[colorIndex];
colorIndex++;
}
var colors = ["#332e2e"];
var colorIndex = 0;
function changeColo() {
var col = document.getElementById("article");
if( colorIndex >= colors.length ) {
colorIndex = 0;
}
col.style.backgroundColor = colors[colorIndex];
colorIndex++;
}
var colors = ["#332e2e"];
var colorIndex = 0;
function changeCol() {
var col = document.getElementById("button");
if( colorIndex >= colors.length ) {
colorIndex = 0;
}
col.style.backgroundColor = colors[colorIndex];
colorIndex++;
}
var colors = ["#332e2e"];
var colorIndex = 0;
function changeCo() {
var col = document.getElementById("div");
if( colorIndex >= colors.length ) {
colorIndex = 0;
}
col.style.backgroundColor = colors[colorIndex];
colorIndex++;
}
var colors = ["#2D2D2D"];
var colorIndex = 0;
function changeC() {
var col = document.getElementById("form-container");
if( colorIndex >= colors.length ) {
colorIndex = 0;
}
col.style.backgroundColor = colors[colorIndex];
colorIndex++;
}
这就是我需要扭转的。我该怎么做?
catspeake
30秒到达战场
守候你守候我
相关分类