$('#nav a').click(function () {
$('#nav a').removeClass('current');
$(this).addClass('current');
return false;
});
My HTML is:
<ul id="nav">
<li><a class="current hoc" href="#spread1-anchor">Home</a> /</li>
<li><a class="bgc" href="#spread2-anchor">Background</a> /</li>
<li><a class="apc" href="#spread3-anchor">Approach</a> /</li>
<li><a class="clc" href="#spread4-anchor">Client</a> /</li>
<li><a class="sec" href="#spread5-anchor">Services</a> /</li>
<li><a class="coc" href="#spread5-anchor">Contact</a></li>
</ul>
And if it helps, my URL is: Karls Example site
Using the above jQuery code – how would I store the last clicked link when the user refreshes the page? Im a beginner with jQuery and even though I have seen answers out there, most of them are to do with sliders or accordions and so are much too complicated for me to understand at this stage of my learning curb! 🙂
Please could someone help and perhaps show how to implement the code or plugin too if one is required (I saw a cookies plugin on my travels around the net)
Do your links have IDs? If so, just store the ID in a cookie when clicked. So, something like this:
Using the jQuery cookie plugin reduces the annoyance factor of setting the cookie directly. On page load, look for the cookie (see documentation), read its value if present, and now you know the ID of the last clicked link.