Following is my code of menus which i include on each page like this,

<?php include('menu.php');?>
<script type="text/javascript"  language="javascript">
$(document).ready(function() {
$('ul#navlist a').click(function() {

$('#navlist .active').removeClass('active');
$(this).parent().addClass('active');
var linkz = $(this).attr("href");
alert(linkz);
return false;
});
});
</script>
<ul id="navlist">
  <li class="active"><a href="index.php"><span>Home</span></a></li>						
  <li><a href="portfolio.php"><span>Our Work</span></a></li>
  <li><a href="services.php"><span>Services</span></a></li>
  <li><a href="request.php"><span>Submit Project</span></a></li>
  <li><a href="contact.php"><span>Contact</span></a></li>
  <li><a href="about.php"><span>About</span></a></li>
</ul>

While selecting menus to move on another page my function removes and adds class to <li>.
But I'm not able to redirect on page related with that menu. var linkz shows the value of active link. How to redirect to page shown in var linkz?

( if you select Home then var linkz=index.php
if you select About then var linkz=about.php and class="active" will removed from Home and will added to About )

Hi Vizz, return false from the click handler suppresses the natural hyperlink action of the clicked <a>. Try removing the statement or returning true.

Most people do this sort of thing with CSS. #navlist a:active {...} will style the clicked link but only while mouse is down.

What you are doing is 100% valid but is it generally not considered important because the page will very shortly be replaced anyway. Would be good for users with slow connections though.

Airshow

Hi Vizz, return false from the click handler suppresses the natural hyperlink action of the clicked <a>. Try removing the statement or returning true.

Most people do this sort of thing with CSS. #navlist a:active {...} will style the clicked link but only while mouse is down.

What you are doing is 100% valid but is it generally not considered important because the page will very shortly be replaced anyway. Would be good for users with slow connections though.

Airshow

Thanks for reply

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.