$('.btn-cart').click(function(e) {
e.preventDefault();
$('.cartlist').fadeIn().addClass('active');
});
$('.btn-cartlist-close').click(function() {
$('.cartlist').removeClass('active').fadeOut();
});
#fadeout{
opacity: 0;
transition: opacity 2s linear;
}
#fadein{
opacity: 1;
transition: opacity 2s linear;
}
#slideSource {
opacity: 1;
transition: opacity 1s;
}
#slideSource.fade {
opacity: 0;
}
.elementToFadeInAndOut {
width:200px;
height: 200px;
background: red;
-webkit-animation: fadeinout 4s linear forwards;
animation: fadeinout 4s linear forwards;
}
@-webkit-keyframes fadeinout {
0%,100% { opacity: 0; }
50% { opacity: 1; }
}
@keyframes fadeinout {
0%,100% { opacity: 0; }
50% { opacity: 1; }
}
/*@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());
event.target.style.transition = '0.8s';
event.target.style.opacity = 0;
var slideSource = document.getElementById('slideSource');
document.getElementById('handle').onclick = function () {
slideSource.classList.toggle('fade');
}
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());
<button id="handle">Fade</button>
<div id="slideSource">Whatever you want here - images or text</div>
Run code snippet