This question has already been answered:
How to implement this through jQuery?
This question has already been answered:
How to implement this through jQuery?
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 .
$('.btn').on('click', function() { $(this).toggleClass('active'); // Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ ΠΈΠ»ΠΈ ΡΠ΄Π°Π»ΡΠ΅ΠΌ ΠΊΠ»Π°ΡΡ ΡΠ°ΠΌΠΎΠΉ ΠΊΠ½ΠΎΠΏΠΊΠ΅ $('div').toggleClass('show'); // Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ ΠΈΠ»ΠΈ ΡΠ΄Π°Π»ΡΠ΅ΠΌ ΠΊΠ»Π°ΡΡ Π½ΡΠΆΠ½ΠΎΠΌΡ Π±Π»ΠΎΠΊΡ }); $("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> Source: https://ru.stackoverflow.com/questions/936544/
All Articles