Toggle between two elements

<div class="toggle-wrap">
  <div id="box-1" class="box active">Click me</div>
  <div id="box-2" class="box">Click me again</div>
</div>
(function ($) {
  $(function () {
    $(".toggle-wrap").click(function () {
      $(this).find(".box").toggleClass("active");
    });
  });
})(jQuery);

// newsletter

Three tested WordPress snippets a week

Blocks, security, performance, Tailwind, PHP and React. Copy, paste, ship. You’ll also get DPlugins product updates. No spam, and you can unsubscribe anytime.

// newsletter

Three tested WordPress snippets a week

Blocks, security, performance, Tailwind, PHP and React. Copy, paste, ship. You'll also get DPlugins product updates. No spam, and you can unsubscribe anytime.

Click to Copy