jQuery fadeIn() with speed and function

Description

jQuery fadeIn() with speed and function

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>//from   ww  w.  j a v  a  2s.  c om
<script>
$(document).ready(function(){
  $(".btn1").click(function(){
    $("p").fadeOut(1000, function(){
      document.getElementById("demo").innerHTML = "fadeOut() method is finished!";
    });
  });
  $(".btn2").click(function(){
    $("p").fadeIn(1000, function(){
      document.getElementById("demo").innerHTML = "fadeIn() method is finished!";
    });
  });
});
</script>
</head>
<body>

<p id="demo"></p>
<p>This is a paragraph.</p>

<button class="btn1">Fade out</button>
<button class="btn2">Fade in</button>

</body>
</html>



PreviousNext

Related