JSFiddle - React, Tailwind, and code Playground

HTML

<div id="div1" >
  Premier texte 
  <button onclick="switch_div('div1','div2')">Next</button>
</div>
<div id="div2" class="cache">
  Deuxieme texte 
  <button onclick="switch_div('div2','div3')">Next</button>
</div>
<div id="div3" class="cache">
  Troisieme texte 
  <button onclick="switch_div('div3','div4')">Next</button>
</div>
<div id="div4" class="cache">
 Dernier texte 
</div>

CSS

.cache {
    display:none;
}

JavaScript

function switch_div(id_elt1,id_elt2)
{
  document.getElementById(id_elt1).classList.toggle("cache");
  document.getElementById(id_elt2).classList.toggle("cache");
}