JSFiddle - React, Tailwind, and code Playground
by c_vilander
HTML
<a href="#" onclick="visibility(id);">Show/Hide</a>
<div id="box">Tadaaa!</div>
CSS
a {
display: block;
margin: 5px;
text-decoration: none;
}
#box {
position: absolute;
top: 10px;
left: 100px;
opacity: 0;
width: 100px;
height: 100px;
background: #000;
border-radius: 5px;
color: #fff;
text-align: center;
-webkit-transition: 2s opacity ease;
transition: 2s opacity ease;
}
JavaScript
function visibility(id) {
var x = document.getElementById('box');
if(x.style.opacity == '0')
x.style.opacity = '1';
else
x.style.opacity = '0';
}