I have no idea how to do this because it is all within the same page…
Please can someone show me how to make this work? So when I click on a different section on the left that link would stay selected and change when you click on another section
Basically what happens now with JimmyP’s code is when you click on a section on the side menu that link stays highlighted which is great. However when you click on an arrow that is in the sections content area it skips to the next section and the sidemenu link is not highlighted anymore.
What I am wondering is how to get the side menu section link to stay highlighted and correspond to the correct section when an arrow is pressed?
Thanks for helping me. The hash script is not working? I have uploaded the site to a test area which can be viewed here
Soon as this hash script works I can make it live (just need to add real pictures).
I would also appreciate it if you could comment on the site in general. If you can see any room for improvement then please let me know your thoughts
If you view the source you will see this:
<script>
jQuery(function( $ ){
$('#gulaab_menu ul li a').click(function(){
$('#gulaab_menu ul li a').removeClass('selected');
$(this).toggleClass('selected');
});
});
</script>
<script>
function checkHash()
var hash = window.location.hash.replace('#', '');
if (!$('#gulaab_menu ul li a[href=#' + hash + ']').hasClass('selected')){
$('#gulaab_menu ul li a').removeClass('selected');
$('#gulaab_menu ul li a[href=#' + hash + ']').toggleClass('selected');
}
setTimeout('checkHash()', 200);
}
checkHash();
</script>
The first script above works but the second is not being picked up?
This is what I am currently using:
jQuery(function( $ ){
$(‘a.next’).click(function(){
$(‘#gulaab_menu ul li a’).removeClass(‘selected’);
$(‘#gulaab_menu ul li a’).toggleClass(‘selected’);
});
});
When you click a.next (View Main Courses >>) it makes all of the menu on the left red… Any ideas how to get this working?
Some more detail on what I want to acheive… Maybe I haven’t explained enough?
After clicking view main courses you will see Chief Specialities >> and so when you click Chief Specialities I want Chief Specialities to highlight on the left menu… You will also see << Starters in the Tandoori page so when you click << Starters I want the Starters link on the left menu to highlight…
i want the next section on the left menu to change color… So Section 1-b link should turn red once clicked on >> this will give more of an indication to the user of what page they are on…
wwwwow yes it works! that is truly genius! thank you so much!
i added removeClass so it the class selected is removed from the old link woohoo!
<script>
jQuery(function( $ ){
$('a.next').click(function(){
$('#gulaab_menu ul li a').removeClass('selected');
var fragment = this.getAttribute('href');
$('#gulaab_menu a[href=' + fragment + ']').toggleClass('selected');
});
});
</script>
That is very clever I thank you again! I am very happy!!! :D:D:D
works like a charm!!!
I have one more question and it is not crucial but it would be good to know if this is possible…
If you click on this link: http://www.gulaab.co.uk/test/menu.php#korma
how can korma be highlighted on the left hand menu?
If you’re clicking from within the page then the link could activate an appropriate behaviour for you.
If someone is going to the page though from somewhere outside, there won’t be an onclick event to trap, so you’ll need to find some other solution.
One solution is to call a function every second to check for any change to the fragment identifier on the address bar, and perform do the appropriate action when that occurs.
The setInterval function lets you call a function on a regular basis
I just realized that this isn’t working in IE… Ive tried to get it working but no luck… Can anyone see why it works in FF and now IE?
jQuery(function( $ ){
$('a.next').click(function(){
$('#gulaab_menu ul li a').removeClass('selected');
var fragment = this.getAttribute('href');
$('#gulaab_menu ul li a[href=' + fragment + ']').toggleClass('selected');
});
});
When you click View Main Courses >> the next option on the land hand menu should highlight… Do this in IE7 to see it work for next and previous options… The class selected isn’t working in IE… Does anyone know why??