I want to maintain the selected color after the page is refreshed or closed and opened again. I've added three buttons to my page for changing background color.
<div id="color">
<button id="blue" onclick="colorBlue()"></button>
<button id="red" onclick="colorRed()"></button>
<button id="green" onclick="colorGreen()"></button>
</div>
And functions in script file.
function colorBlue() {
document.body.style.backgroundColor = '#002E5C';
}
function colorRed() {
document.body.style.backgroundColor = '#BA1616';
}
function colorGreen() {
document.body.style.backgroundColor = '#118E1B';
}
This is for a school project and it should be done using cookies. I tried to do it myself, but with no success. Thanks in advance!