How would i store the color of an element, after page refresh when the user has selected the required color? In essence the color needs to stay the same color the user selected before page refresh.
I am able to change the color when a color has been chosen.
HTML
<body onload="changeColor()">
<h1 id="Myelement">This is a heading</h1>
<input type="color" id="get_color" onchange="changeColor()">
Script
<script>
function changeColor() {
let color_picker = document.getElementById('get_color').value;
localStorage.setItem("color", color_picker);
document.getElementById("Myelement").style.color = localStorage.getItem("color");
document.getElementById("Myelement").style.transition = "all 1s";
}
</script>