JSFiddle - React, Tailwind, and code Playground
HTML
<button>Toggle</button>
<p hidden>Coucou !</p>
CSS
[hidden]{
display: none
}
JavaScript
Object.defineProperty(HTMLElement.prototype, "hidden", {
get: function(){ return this.hasAttribute('hidden') },
set: function(bool){
if(bool){ this.setAttribute('hidden', '') }
else { this.removeAttribute('hidden') }
}
})
document.querySelector("button").onclick = function(){
console.log(this.nextSibling)
this.nextElementSibling.hidden = !this.nextElementSibling.hidden
}