Answers for "javascript fade out element"

2

css fade out

/* Just add .fade-out class to element */

.fade-out {
	animation: fadeOut 2s;
  	opacity: 0;
}

@keyframes fadeOut {
  from {
  	opacity: 1;
  }
  to {
 	opacity: 0;
  }
}
Posted by: Guest on April-30-2021
1

jquery on click fade out element

$(document).ready(function(){
  $("button").click(function(){
    $("p").fadeOut();
  });
});
Posted by: Guest on June-02-2020
0

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>
Posted by: Guest on August-18-2021
5

css fade out

/* Answer to: "css fade out" */

/*
  With the code below, all you have to do is use JavaScript to
  give the element ".hide-opacity" and it'll fade-out.

  Feel free to edit this code so it works on hover, focus, active
  or any other special selector possible with CSS and of course
  feel free to use this code with your JavaScript too!
*/

.successfully-saved {
    color: #FFFFFF;
    text-align: center;

    -webkit-transition: opacity 3s ease-in-out;
    -moz-transition: opacity 3s ease-in-out;
    -ms-transition: opacity 3s ease-in-out;
    -o-transition: opacity 3s ease-in-out;
     opacity: 1;
}

.successfully-saved.hide-opacity {
    opacity: 0;
}
Posted by: Guest on April-27-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language