По другому сделал и заработало, я стал править сам стиль а не стили.
И не понимаю как лучше сделать
const body = document.querySelector("body");
const knopka_1 = document.querySelector(".knopka_1");
const knopka_2 = document.querySelector(".knopka_2");
const knopka_3 = document.querySelector(".knopka_3");
const knopka_4 = document.querySelector(".knopka_4");
let fun_knopka_1 = () => {
body.style.backgroundColor = "#fff";
body.style.color = "#000";
localStorage.setItem("belyi_fon", "#fff");
localStorage.removeItem("chernyi_fon");
}
knopka_1.addEventListener("click", fun_knopka_1);
let fun_1 = () => {
if (localStorage.getItem("belyi_fon")!==null){
body.style.backgroundColor = "#fff";
body.style.color = "#000";
}
}
window.addEventListener("load", fun_1);
let fun_knopka_2 = () => {
body.style.backgroundColor = "#000";
body.style.color = "#fff";
localStorage.setItem("chernyi_fon", "#000");
localStorage.removeItem("belyi_fon");
}
knopka_2.addEventListener("click", fun_knopka_2);
let fun_2 = () => {
if (localStorage.getItem("chernyi_fon")!==null){
body.style.backgroundColor = "#000";
body.style.color = "#fff";
}
}
window.addEventListener("load", fun_2);
let fun_knopka_3 = () => {
body.style.fontSize = "0.8rem";
localStorage.setItem("osnovnoi_razmer", ".8rem");
localStorage.removeItem("uvelichenyi_razmer");
}
knopka_3.addEventListener("click", fun_knopka_3);
let fun_3 = () => {
if (localStorage.getItem("osnovnoi_razmer")!==null){
body.style.fontSize = "0.8rem";
}
}
window.addEventListener("load", fun_3);
let fun_knopka_4 = () => {
body.style.fontSize = "1.6rem";
localStorage.setItem("uvelichenyi_razmer", "uvelichenyi_razmer");
localStorage.removeItem("osnovnoi_razmer");
}
knopka_4.addEventListener("click", fun_knopka_4);
let fun_4 = () => {
if (localStorage.getItem("uvelichenyi_razmer")!==null){
body.style.fontSize = "1.6rem";
}
}
window.addEventListener("load", fun_4);