JavaScript (jQuery?): Toggle multiple classes with one click

后端 未结 2 889
天涯浪人
天涯浪人 2021-01-27 02:10

When the user clicks div.togglethis, I need two things to happen:

  1. Add an \"active\" class to div.togglethis

  2. Add a \"show\" class to an outside

2条回答
  •  一生所求
    2021-01-27 03:10

    You should look at jQuery's addClass, removeClass, toggleClass, and hasClass methods (API references here, here, here, and here).

    You would call these methods in the click handler for div.togglethis. Give this a try and post another question if you get stuck.

提交回复
热议问题