Javascript/Jquery to change class onclick?

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

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



        
相关标签:
8条回答
  • 2020-12-01 15:37

    I would think this: http://jsfiddle.net/Skooljester/S3y5p/1/ should do it. If I don't have the class names 100% correct you can just change them to whatever you need them to be.

    0 讨论(0)
  • 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");
       }
    });
    
    0 讨论(0)
提交回复
热议问题