Posted By

loric on 06/18/10


Tagged

jqueryjavascriptnavnavigationmenuhighlightselecteditemactive


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

binshtok
jeremyalfordgmailcom


Highlight selected navigation or menu item


 / Published in: jQuery
 

  1. $('nav a').each(function()
  2. {
  3. var hreflink = $(this).attr("href");
  4. if (hreflink.toLowerCase()==location.href.toLowerCase())
  5. {
  6. $(this).addClass('selected');
  7. }
  8. });

Report this snippet  

You need to login to post a comment.