JSFiddle - React, Tailwind, and code Playground
by kspr
HTML
<p class="toggle-content" id="contenido-1">Hola mundo!</p>
<a href="#" onclick="return toggle(1)">abrir/cerrar</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;
}