Backspace active li class jquery

I have a little problem with some jquery and http://www.mikage.to/jquery/jquery_history_noc.html

The function works great, my problem is to highlight the li class, the tab menu when the user accesses the keyboard, or just use the back button in their browser to return the last viewed page.

html code

li code with active class when page is enabled

<li class="active"><a href="#prices" rel="history"><span>Prices</span></a></li>

      

jquery code:

This is loaded when

$(document).ready 
    $('li > a').click(function() {
    $('li').removeClass();
    $(this).parent().addClass('active');        
});

      

Can I do som .... keyCode == 8 (backspace key) to return the last page? Can someone give me a hint, or mabye give me some example code: - /

+2


source to share


1 answer


I would consider storing the state in a cookie (like whether a class is added to an element), and reinitializing your page from the values ​​written to the cookie in your function $(document).ready

. I did something like this to expand the extended bits of the page. Check out the jQuery cookie plugin .



+2


source







All Articles