How to preserve link state or CSS class on a link (anchor tag) with cookies?

How to preserve link state or CSS class on a link (anchor tag) with cookies?

Hello,

I have this piece of code which adds and remove a class on my links.
The class is added to the linked clicked or active and removed from liked that are not active/clicked.

However I would like to preserve the state of the active link so that it remain active even when the page is refreshed, this is for a single page.

JQuery:






  1. $(document).ready(function() {	
        $('.navbar li a').click(function(){
            $(".navbar li a").removeClass("currentTab");
            $(this).addClass("currentTab"); 
        }); 
    });

CSS:
  1. <style type="text/css">
    .currentTab{
    color: #999999;
    }
    </style>



HTML:
  1. <ul class="navbar">
    <li><a href="#/">Test Link</a></li>
    <li><a href="#/">Test Link</a></li>
    <li><a href="#/">Test Link</a></li>
    </ul>



Thanks everyone!

 

AR