Like people are saying in the commends you can use html 5 web storage.
You have 2 types:
- localStorage - stores data with no expiration date
- sessionStorage - stores data for one session
how to set:
localStorage.setItem("name", "value");
How to get the value
localStorage.getItem("name");
So now can you do a simple check like:
if (localStorage.getItem("toggle") === null) {
//hide or show menu by default
//do not forget to set a htlm5 cookie
}else{
if(localStorage.getItem("toggle") == "yes"){
//code when menu is visible
}else{
//code when menu is hidden
}
}
More information here
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…