Add class=“active” to active page using PHP

前端 未结 10 763
你的背包
你的背包 2020-12-01 06:47

Dynamic Header, CSS Class Change To Active USING PHP (dirrectory)

I want the class of the

  • tag to change under the active dirrectory... now
  • 10条回答
    •  攒了一身酷
      2020-12-01 07:26

      Maybe this helps you:

      $(document).ready(function()
      {
          var parts = document.URL.split("/");
          // [http:, empty, your domain, firstfolder]
          var firstFolder = parts[3];
      
          $("#mainnav li").attr("class", "noactive");
          $("#mainnav a[href='/" + firstFolder + "/']").parent().attr("class", "active");
      });
      

    提交回复
    热议问题