Jquery Add active class to main menu

前端 未结 4 1099
别跟我提以往
别跟我提以往 2020-12-06 21:26

I\'m trying to add dynamic active class to my main menu, but i can\'t able to achieve this,

My jquery is,



        
4条回答
  •  悲哀的现实
    2020-12-06 21:47

    Your description is not very clear. By active if you mean the list-item you are hovering on then it should be something like this:

    $('a.menu').hover(
    
    function () {
        $(this).addClass("active");
    },
    
    function () {
        $('a.menu').removeClass("active");
    });
    

提交回复
热议问题