JSFiddle - React, Tailwind, and code Playground
HTML
<textarea cols="50" id="textarea">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</textarea><br />
<input type="button" value="toggle" onclick="$elect('textarea').toggle()" />
JavaScript
function $elect(id) {
if (window === this) {
return new $elect(id);
}
this.elm = document.getElementById(id);
}
$elect.prototype = {
hide: function () { this.elm.style.display = 'none'; },
show: function () { this.elm.style.display = ''; },
toggle: function ()
{
if (this.elm.style.display !== 'none') {
this.elm.style.display = 'none';
} else {
this.elm.style.display = '';
}
}
};