setting active class and removing it from all others

前端 未结 1 898
盖世英雄少女心
盖世英雄少女心 2021-01-14 10:19

I\'ve got a couple of divs to scroll between. I need to set the one in active view (after a link was clicked) to \'active\' and all the other div\'s should have that class r

相关标签:
1条回答
  • 2021-01-14 11:06

    why not just use addClass and removeClass:

    $(".selected").removeClass("selected"); 
    $(this).addClass("selected");
    

    to only remove selected from divs use this for the first line:

    $("div.selected").removeClass("selected"); 
    
    0 讨论(0)
提交回复
热议问题