Jekyll - Automatically highlight current tab in menu bar

后端 未结 12 1002
鱼传尺愫
鱼传尺愫 2020-12-22 15:34

I am using github to host a static site and Jekyll to generate it.

I have a menu bar (as

    ) and would like the
  • correspo
12条回答
  •  清酒与你
    2020-12-22 15:56

    Here is a jQuery method to do the same

      var pathname = window.location.pathname;
    
      $(".menu.right a").each(function(index) {
        if (pathname === $(this).attr('href') ) {
          $(this).addClass("active");
        }
      });
    

提交回复
热议问题