Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could use a Cookie to hold the value of the currently open menu. This will allow for the value to be saved/retrieved between page loads and browser sessions.</p> <p>As you've already got jQuery setup you can use the <a href="https://github.com/carhartl/jquery-cookie" rel="nofollow">jQuery Cookie plugin</a> to simplify things.</p> <p>The code for it is quite simple (more examples on plugin page).</p> <pre><code>$.cookie('open_menu', 'projects'); //Save 'projects' under 'open_menu' $.cookie('open_menu') //Returns 'projects' </code></pre> <p>Just check the value on page load and save it when one of the menu's is clicked.</p> <p>If you'd prefer not to add any extra plugins here's some documentation on <a href="https://developer.mozilla.org/en-US/docs/DOM/document.cookie" rel="nofollow">JavaScript's inbuilt cookie API</a>.</p> <p>Edit: I've created a <a href="http://jsfiddle.net/Dracs/qMrBe/" rel="nofollow">JSFiddle</a> with an example for you. The Cookie code doesn't seem to work in there sandbox, but the code should work for you, let me know if you have any troubles.</p> <pre><code>$(window).load(function() { if ($.cookie('show_menu') !== undefined) { $('#' + $.cookie('show_menu')).click(); } $('.nav &gt; li &gt; ul').each(function () { //Hide the sub lists $(this).hide(); //Get link with same ID as Class var id = $(this).attr('id'); //When link is clicked $('.' + id).click(function () { //Get the sub list var list = $('#' + $(this).attr('class')); //Check if it's currently visible if (list.is(':visible')) { list.hide(); //Hide list $.cookie('show_menu', ''); //Unset open menu } else { $('.nav &gt; li &gt; ul').hide(); //Hide all other lists list.show(); //Show list $.cookie('show_menu', list.attr('class')); //Set open menu } }); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload