How can I use jQuery to highlight the current page? In other words, add a "current" class to the a element of the current page.
Here's my code:
<div id="nav">
<ul>
<li><a href="../articles/">Articles</a></li>
<li><a href="../photos/">Photos</a></li>
<li><a href="../info/">Earthquake Info</a></li>
</ul>
</div>
I've researched several different approaches, but most of them rely on linking to pages (i.e. articles.html
) instead of directories (i.e. ../articles/
).
I've seen the body/ID class method and would prefer an automatic jQuery solution.