Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript Element fade out

/*@lang css

#target {
    height: 100px;
    background-color: red;
    transition: opacity 1s;
}

*/

const target = document.getElementById("target");

target.addEventListener('click', () => target.style.opacity = '0');
// If you want to remove it from the page after the fadeout
target.addEventListener('transitionend', () => target.remove());
Source by newbedev.com #
 
PREVIOUS NEXT
Tagged: #JavaScript #Element #fade
ADD COMMENT
Topic
Name
6+2 =