JSFiddle - React, Tailwind, and code Playground

by BramVanroy

HTML

<div>
      <p>Text 1</p>
      <p>Text 2</p>
      <p>Text 3</p>
    </div>
    
    <button>toggle 1</button>
    <button>toggle 2</button>
    <button>toggle 3</button>

CSS

p {display: none;}

JavaScript

$("button").click(function() {
    var $this = $(this),
        thisNumber = $this.index();
        
        $("p:nth-child(" + thisNumber + ")").toggle("fast");
});