Here is a simple way to change the color of elements on your webpage:
<button id="btnChangeColor" class="btn btn-primary">Change Color</button>
Use JavaScript to add an event listener to the button and select all elements you want to change with the DOM.
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 customize the CSS class (custom-theme) with your preferred values:
.custom-theme {
background-color: green;
color: white;
}