This question has already been answered:

How to implement this through jQuery?

Reported as a duplicate by participants 0xdb , Misha Saidov , AK ♦ , Community Spirit ♦ Jan 25 at 1:00 pm .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    2 answers 2

    $('.btn').on('click', function() { $(this).toggleClass('active'); // добавляСм ΠΈΠ»ΠΈ удаляСм класс самой ΠΊΠ½ΠΎΠΏΠΊΠ΅ $('div').toggleClass('show'); // добавляСм ΠΈΠ»ΠΈ удаляСм класс Π½ΡƒΠΆΠ½ΠΎΠΌΡƒ Π±Π»ΠΎΠΊΡƒ }); 
    • Thanks for the answer) - user324082

     $("button").on("click", () => { $("p").toggleClass("red"); }); 
     .red { background-color: red; } 
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <p>Hello world</p> <button>Click me</button>