I think that the best thing to do would be to create classes for each color (e.g., dark, light, default) and when you click the button changes only the class of the parent element, the rest is already set inside.
ex:
var dark = document.getElementById('btnDark');
var light = document.getElementById('btnLight');
var initial = document.getElementById('btnInitial');
var body = document.querySelector('body');
dark.onclick = function(){
body.className = "dark";
}
light.onclick = function(){
body.className = "light";
}
initial.onclick = function(){
body.className = "";
}
.dark{
background:#000;
color:#fff;
}
.light{
background:#fff;
color:#4b4b4b;
}
<body>
<h2>Lorem Ipsum é simplesmente</h2>
<p>Lorem Ipsum é simplesmente uma simulação de texto da indústria tipográfica.</p>
<button id="btnDark">Dark</button>
<button id="btnLight">Light</button>
<button id="btnInitial">Default</button>
</body>
Use Sass to create classes, it would make it much easier.
PS: In the above example I didn’t use any library.
permanent change?
– Wees Smith
Yes, at least until the user clicks another button to change to another color, or until the user refreshes the page.
– Nelson Pacheco
So it’s not permanent, you can just use
Jquery
and change when click, when update it goes back to normal– Wees Smith
Thank you very much.
– Nelson Pacheco
I’ll post an example
– Wees Smith