I have made a simple function that shows some content if you press a specific button. My problem is just that I don't know how to save that action even if you reload the page.
Here is my HTML:
<div class="content1" style="display: none;">
<p style="color: green;">Some content from content1</p>
</div>
<div class="content2" style="display: none;">
<p style="color: red;">Some content from content2</p>
</div>
<button class="content1-btn">Button 1</button>
<button class="content2-btn">Button 2</button>
Here is my jQuery:
$(document).ready(function(){
$(".content1-btn").click(function(){
$(".content1").show();
});
$(".content2-btn").click(function(){
$(".content2").show();
});
});
The above code works well enough as it should. The problem is that I want a cookie to remember witch button you have clicked on. If for example you click button 1, then .content1 should still be displayed even if you reload the page. I hope it makes sense.