i got this script to add to some "li"'s the class "activeyo" when someone clicks it.The links realod the same page , but after the page is reloaded the added class is gone. I readed this: https://developer.mozilla.org/en-US/docs/DOM/Storage and this Remembering jQuery tab position after page reloads
But i cant understand how to properly use the local storage so i can css properly the li's even after the reload.
$(document).ready(function() {
$('#alpha_ul li a ').click(function() {
$('#alpha_ul li a ').removeClass("activeyo");
$(this).addClass("activeyo");
});
});
Tried code:
function yo(alpha) {
$('#alpha_ul li a ').removeClass("activeyo");
alpha.addClass("activeyo");
}
$("#alpha_ul li a").click(function () {
if (localStorage) localStorage['alpha'] = $(this).closest('li').index();
yo($(this));
});
});
The above code does exactly what the first block of code does. after refresh the class is removed.