Highlight selected navigation or menu item


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.