Using the code below, I want to keep the same menu div opened in the next page. I probably need to use cookies, but I don’t know how cookies work in JavaScript.
$(this)
.css({backgroundColor:"#861b1b"})
.next("div.menu_body")
.slideToggle(300)
.siblings("div.menu_body")
.slideUp("slow");
$(this).siblings().css({backgroundColor:"#eee"});
Provided the browser allows it, cookies are accessed with:
There’s also a good jQuery plugin for dealing with them: https://github.com/carhartl/jquery-cookie
Read the README file for examples and instructions.
A simple example to get you started. First, when the user clicks on a menu:
Next, when the page loads:
OpenMenu should contain the code you posted above. Make sure that your menu items have unique ids.