Try this
First create a button HTML whit the id "btnChangeColor"
<button id="btnChangeColor" class="btn btn-primary">Change Color</button>
With JavaScript add the listener and with the DOM get all elements to change.
const btnChangeColor = document.querySelector('#btnChangeColor');
const footer = document.querySelector('footer');
const divs = document.querySelectorAll('div');
btnChangeColor.addEventListener('click', () => {
footer.classList.add('custom-theme');
divs.forEach(item => {
item.classList.add('custom-theme');
});
});
You can custom the class CSS (custom-theme) with the values with you prefer
.custom-theme {
background-color: green;
color: white;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…