JSFiddle - React, Tailwind, and code Playground
by c_vilander
HTML
<a href="#" onclick="showHide()">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 showHide() {
var x = document.getElementByID('box');
if (x.style.opacity == '0')
{
x.style.opacity = '1';
}
else if (x.style.opacity == '1')
{
x.style.opacity = '0';
}
}