Javascript/Jquery to change class onclick?

后端 未结 8 2176
北海茫月
北海茫月 2020-12-01 15:13

I want to change a class onclick. What I have at the moment:



        
8条回答
  •  温柔的废话
    2020-12-01 15:40

    Another example is:

    $(".myClass").on("click", function () {
       var $this = $(this);
    
       if ($this.hasClass("show") {
        $this.removeClass("show");
       } else {
        $this.addClass("show");
       }
    });
    

提交回复
热议问题