Work with legacy and simple sites using jQuery selectors, events, AJAX, effects, and plugins.
Lessons
Flip classes on and off based on state.
toggleClass() is easiest to learn by reading the example, changing it, and observing the result.
$('#tab').on('click', function () {
$('.tab').removeClass('active');
$(this).addClass('active');
});
$('#theme').on('click', function () {
$('body').toggleClass('dark');
});
console.log($('#box').hasClass('active'));Practice the toggleClass() example in a small scratch file, then explain what changed and why.