Task at Hand :
- Implement a smooth element hiding effect upon clicking, similar to the behavior on this website , where the letter A fades away smoothly when clicked.
- Is it possible to achieve this effect using only HTML, CSS, and JavaScript?
var targetElement = document.getElementById('target-element');
document.getElementById('hide-button').onclick = function () {
targetElement.className = 'hidden';
};
document.getElementById('show-button').onclick = function () {
targetElement.className = '';
};
#target-element {
transition-property: visibility, opacity;
transition-duration: 0s, 1s;
}
#target-element.hidden {
opacity: 0;
visibility: hidden;
transition-property: opacity, visibility;
transition-duration: 1s, 0s;
transition-delay: 0s, 1s;
}
<a href="#" id="target-element">Text</a>
<button id="hide-button">Hide</button>
<button id="show-button">Show</button>