Bootstrap menu change li active class on click

前端 未结 6 1596
予麋鹿
予麋鹿 2021-02-05 09:12

I have the following menu by bootstrap

HTML

6条回答
  •  佛祖请我去吃肉
    2021-02-05 09:47

    Try this:

    $("ul li").on("click", function() {
        $("li").removeClass("active");
        $(this).addClass("active");
      });
    

    You will have to play around with it with your given tags. What helped me was declaring this to become active, then removing the active class.

提交回复
热议问题