In my application, there is an option for the user to change the CSS of the page on click of a button. I want that the selected style should remain if the user visits another link on the page or if the page is reloaded, i.e. the user should not have to select the style/theme of choice again and again.
How can I achieve this ?
function switch_style (style){
if(theme == "blue"){
document.getElementById("test").setAttribute('style','color:blue');
}
else if(theme == "black"){
document.getElementById("test").setAttribute('style','color:black');
}
}
<button type="button" class="btn btn-dark" onclick="switch_style('blue') id="blue">Blue</button>
<button type="button" class="btn btn-dark" onclick="switch_style('black')id="black">Black</button>
<p id="test">SAMPLE TEXT</p>