If you want to use this to show the user which sub-page on your site he/she is on, you have to use some sort of serverside-coding (Examples: PHP, ASP, ASP.NET, Python, Ruby or similar) to assign a specific class to the element corresponding with the current page.
The reason for this is, that Javascript cannot be stored between different page loads, so when the link is clicked and changed with Javascript, this will be reset when the new page (that you just requested) is loaded.
If your site consists of just a few flat HTML-pages, you're best off by adding the classes to the correct menu items manually.
Example of how you can arrange your menu:
page1.html
<ul id="menu">
<li><a href="page1.html" class="activeSection">Menuitem 1</a></li>
<li><a href="page2.html">Menuitem 2</a></li>
<li><a href="page3.html">Menuitem 3</a></li>
<li><a href="page4.html">Menuitem 4</a></li>
</ul>
page2.html
<ul id="menu">
<li><a href="page1.html">Menuitem 1</a></li>
<li><a href="page2.html" class="activeSection">Menuitem 2</a></li>
<li><a href="page3.html">Menuitem 3</a></li>
<li><a href="page4.html">Menuitem 4</a></li>
</ul>
Note the position of class="activeSection"
- this is what decides where the CSS is applied that changes the look of the selected page.