I have a banner fixed at the bottom of my website that is open by default to display important information, I also have a button that can toggle it away if the user has read the notice and wants to hide it.
This is my js:
$(document).ready(function(){
const noticeToggle = document.querySelector('.notice__toggle'),
notice = document.querySelector('.notice')
noticeToggle.addEventListener('click', _ => {
noticeToggle.classList.toggle('notice__toggle--toggled');
notice.classList.toggle('notice--toggled');
})
});
Is there a way I can use js, cookies or something else to save the state of this toggle whilst the user is on the website? Currently it only defaults to open when they navigate different pages (as expected).