Now I have two divas, by clicking on which the value of the variable changes. And depending on this value, the background of the site changes. This is done like this:
document.body.classList.add('n1'); body.n1 { background-image: url("/images/fon/43.jpg"); } But the change itself happens only after the page is updated, so I had to make a div inside the empty link:
<a href=""> <div id="fon2" class="fon2"> <img src="/images/main3.jpg" alt="текст"> </div> </a> Can I make a background change without refreshing the page?