I have created a code that when you select an option in a select to the body of my website includes a new attribute in class with setAttribute, but my problem is that it deletes the other attribute of the dark mode.
The intention of the code is to change some colors of the web site and that it stays saved to the local storage.
What can I change?
function wow(value) {
var index = {
chb: "griegos",
cj: "romanos",
hv: "celtas"
};
document.getElementById("body").setAttribute("class", index[value]);}
.griegos {background: orange}
.romanos {background: purple}
.celtas {background: green}
<body id="body" class="griegos dark">
<select class="forminput" onchange="wow(this.value)"><option value="chb">Camp Half-Blood</option><option value="cj">Camp Jupiter</option><option value="hv">Hotel Valhalla</option></select></div>