I was wondering if anyone could help me with a current page selection for my navigation bar. I am a noob to javascript and jquery and I would like to use jquery for this. I don't know how to implement it. I have a drop down menu.
I have found the following and was wondering why they don't work for me please tell me anything you can think of I'm probrably using it in the wrong section. I have tried in the head and in the body. But i was under the impression that only plugins needed to go in the head idk please help.
(Note: I have change the selected to my the class i styled, if that might also be a mistake.)
Here are the links:
http://docs.jquery.com/Tutorials:Auto-Selecting_Navigation
$(function(){
var path = location.pathname.substring(1);
if ( path )
$('#sidebar_content a[href$="' + path + '"]').attr('class', 'selected');
});
http://css-tricks.com/snippets/jquery/highlight-all-links-to-current-page/
$(function(){
$("a").each(function(){
if ($(this).attr("href") == window.location.pathname){
$(this).addClass("selected");
}
});
});
please keep in mind im a noob and i might need a little more detail in order to understand. Thanks in advance.