0

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 )

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by vizz
0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.