Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to do:</p> <pre><code>$('#menu') &lt;-- note the # sign </code></pre> <p>in your selectors.... Otherwise it looks like it should work OK</p> <p>API Reference: <a href="http://api.jquery.com/id-selector/" rel="nofollow noreferrer" title="jQuery ID Selector">jQuery ID Selector</a></p> <p>To address your edit:</p> <p>Element state is not automatically preserved between page loads. The browser doesn't look for "the same element" and try to make it appear the same. If you want the menu to remain open, you need to persist some data (whether through postback data or (I would recommend) some browser side state saving (e.g. <code>localStorage</code>)) and handle it manually in your menu code </p> <p>Oh....rereading your question I think it might be simpler than that....</p> <p>On page load, you could do something like:</p> <pre><code>$('[href=' + window.location.path + ']').addClass('active'); </code></pre> <p>the <code>window.location.path</code> would likely need some pre-processing before the selector though to handle extra url parameters and variations of the path (e.g. <code>./index.html</code> and <code>index.html</code>) in the href. However, note the various types of matching available with the attribute selector...namely <code>*=</code>...might make your href matching a lot easier...but I'm not gonna write all your code =0D</p> <p>API Reference: <a href="http://api.jquery.com/category/selectors/attribute-selectors/" rel="nofollow noreferrer">jQuery Attribute Selector</a></p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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