Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
Or, if you're like me (I'm super lazy), you will do it all with JavaScript. This is for a navigation with an id of "menu" on it:
Code:
<script type="text/javascript">
var nav=document.getElementById("menu").getElementsByTagName("a");
for(var i in nav) {
if(nav[i].href==window.location) {
nav[i].className="active";
}
}
</script>
If the href of a link is the same as the location of the window within "#menu", it will add a class of "active" to the <a>, which can be styled from the CSS document. Just put the script at the bottom of the page, or right underneath the menu.
Last edited by wayfarer07; 11-25-2008 at 03:26 PM..
|