Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

vanilla javascript fade out

<div id="target">Click to fade</div>
<script>
  function fadeOutEffect() {
    var fadeTarget = document.getElementById("target");
    var fadeEffect = setInterval(function () {
        if (!fadeTarget.style.opacity) {
            fadeTarget.style.opacity = 1;
        }
        if (fadeTarget.style.opacity > 0) {
            fadeTarget.style.opacity -= 0.1;
        } else {
            clearInterval(fadeEffect);
        }
    }, 200);
}

document.getElementById("target").addEventListener('click', fadeOutEffect)
</script>
<style>
  #target {
    height: 100px;
    background-color: red;
}
</style>
Comment

javascript fadein fadeout

#slideSource {
  opacity: 1;
  transition: opacity 1s; 
}

#slideSource.fade {
  opacity: 0;
}
Comment

vanilla js fade in fade out

event.target.style.transition = '0.8s';
event.target.style.opacity = 0;
Comment

javascript fadein fadeout

var slideSource = document.getElementById('slideSource');

document.getElementById('handle').onclick = function () {
  slideSource.classList.toggle('fade');
}
Comment

javascript fadein fadeout

<button id="handle">Fade</button> 
<div id="slideSource">Whatever you want here - images or text</div>
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Javascript :: NodeJS 10.24.1 
Javascript :: js match img 
Javascript :: javascript debugger online 
Javascript :: new array from javascript 
Javascript :: xmlhttprequest status codes 
Javascript :: Substring in Javascript using substr 
Javascript :: start live server react js 
Javascript :: react native stylesheet shortcut 
Javascript :: find object in array 
Javascript :: vue css 
Javascript :: sort numbers in array javascript 
Javascript :: loading react 
Javascript :: jquery get native element 
Javascript :: how to find the lowest number in an array in javascript for specific indexes 
Javascript :: object promise javascript 
Javascript :: react: fow to use find(to get the id of a element 
Javascript :: why geting empty array from mongodb 
Javascript :: radio button not checked 
Javascript :: how to style navigation drawer react navigation v5 
Javascript :: append string js 
Javascript :: destructuring in es6 
Javascript :: how to find element in array angularjs 
Javascript :: Basic Vue JS Setup script for Laravel App 
Javascript :: open modal on clicking select option in react 
Javascript :: string comparison javascript 
Javascript :: looping through json array 
Javascript :: react testing library 
Javascript :: xml http request fetch 
Javascript :: .then javascript 
Javascript :: is checked jquery not working 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =