JSFiddle - React, Tailwind, and code Playground
HTML
<p class="toggle-content" id="contenido-1">Hola mundo 1!</p>
<a id="myText-1" href="#" onclick="return toggle(1)">abrir/cerrar 1</a>
<br>
<p class="toggle-content" id="contenido-2">Hola mundo 2!</p>
<a id="myText-2" href="#" onclick="return toggle(2)">abrir/cerrar 2</a>
<br>
<p class="toggle-content" id="contenido-3">Hola mundo 3!</p>
<a id="myText-3" href="#" onclick="return toggle(3)">abrir/cerrar 3</a>
CSS
.toggle-content {
display: none;
}
JavaScript
function toggle (id) {
var toggleable = document.querySelector('#contenido-' + id);
if (!toggleable) return;
if (!toggleable.style.display
|| toggleable.style.display === 'none') {
toggleable.style.display = 'block';
} else {
toggleable.style.display = 'none';
}
return false;
}