jQuery add class to current li and remove prev li when click inside li a

后端 未结 7 533
执笔经年
执笔经年 2020-12-28 08:55

here is html:

7条回答
  •  暖寄归人
    2020-12-28 09:31

    Maybe you mean this?

    $('ul li').each(function(){
      var t = $(this);
      t.find('a').click(function() {
        $('ul li').removeClass('current');
        t.addClass('current');
      });
    });
    

提交回复
热议问题