Bootstrap menu change li active class on click

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

I have the following menu by bootstrap

HTML

6条回答
  •  一整个雨季
    2021-02-05 09:37

    one of your selectors is malformed, by looking at your html it looks like on the third line of the script that selector isn't doing what I think you want it to.

    $("#homeL, #workL").click(function(){
    
      //$(".nav navbar-nav li") <-this is looking for a 
  • inside a // tag inside a tag with the class "nav" $(".nav.navbar-nav li").removeClass("active"); $(this).addClass("active"); });
提交回复
热议问题