JSFiddle - React, Tailwind, and code Playground

HTML

<button>one</button>
<div class="div1"></div>
<button>two</button>
<div class="div2"></div>
<button>three</button>
<div class="div3"></div>
<button>four</button>
<div class="div4"></div>

CSS

button{display: block; width: 170px;}

button + div{width:170px;height:80px;background-color:red; display: none;}

JavaScript

$(document).ready(function(){
  $("button").click(function(){
      $('[class^=div]:visible').not($(this).next().slideToggle()).slideUp();
  });
});