I am trying to use jquery to build a top navigation. When a link button/menu is selected the button should be higlighted and display the selected item and when its goes to that page selected.
Is there anyway to do this. I have this script it kinda works but not completely.
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#hdcnav ul li a').click(function() {
$('#hdcnav ul').find('img').each(function(){
var imgsrc = $(this).attr('src');
if(imgsrc.indexOf('selected')>=0){$(this).attr('src',imgsrc.split('-')[0]+".gif");}
});
$(this).find('img').attr('src',$(this).find('img').attr('src').split('.')[0]+"-selected.gif");
});
});
</script>
</head>
<body>
<div id="nav">
<ul>
<li><a href="page1.html"><img src="images2.gif" alt="home" /></a></li>
<li><a href="page2.html"><img src="images3.gif" alt="" /></a></li>
<li><a href="page3.html"><img src="images4.gif" alt="" /></a></li>
<li><a href="#"><img src="images4.gif" alt="" /></a></li>
<li><a href="#"><img src="images5.gif" alt="" /></a></li>
<li><a href="#"><img src="images6.gif" alt="" /></a></li>
</ul>
</div>