addClass and removeClass in jQuery - not removing class

后端 未结 10 1618
不知归路
不知归路 2020-12-05 02:02

I\'m trying to do something very simple. Basically I have a clickable div \'hot spot\', when you click that it fills the screen and displays some content. I achieved this by

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 02:52

    Try this :

    $('.close-button').on('click', function(){
      $('.element').removeClass('grown');
      $('.element').addClass('spot');
    });
    
    $('.element').on('click', function(){
      $(this).removeClass('spot');
      $(this).addClass('grown');
    });
    

    I hope I understood your question.

提交回复
热议问题