title: How to set active class to menu item (sessionStorage)
body: <p>I have code like this: </p>
  
  <pre><code>&lt;ul class="nav navbar-nav navbar-right"&gt;
      &lt;li&gt;&lt;a href="#" class="dropdown-toggle " data-toggle="dropdown" data-hover="dropdown" data-close-others="true"&gt;Some &lt;i class="fa fa-caret-down" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;
         &lt;ul class="dropdown-menu"&gt;
            &lt;li&gt;&lt;a href=""&gt;Some 1&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=""&gt;Some 2&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=""&gt;Some 3&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=""&gt;Some 4&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href=""&gt;News&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>And JS code</p>
  
  <pre><code>$(document).ready(function () {
  
      $(".nav  li a ").click(function () {
      var id = $(this);
  
      $(".nav li a").removeClass("active");
      $(id).addClass("active");
      sessionStorage .setItem("mylink", $(id).text());
     });
  
      var mylink = sessionStorage .getItem('mylink');
  
      if (mylink !== null) {
  
         $("li:contains('" + mylink + "')").addClass("active");
       }
  });
  </code></pre>
  
  <p>I’m trying to achieve that, when I click an on the item in my nav adds “active” class. Can somebody help me with this?</p>