Highlight All Links To Current Page

0
0
$(function(){
       $("a").each(function(){
               if ($(this).attr("href") == window.location.pathname){
                       $(this).addClass("selected");
               }
       });
});

This function will add the class “selected” to any links (even relative) that point to the current page.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.