jQuery hide() with callback function

Description

jQuery hide() with callback 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 w  w w  . ja  va  2 s  . c  om*/
<script>
$(document).ready(function(){
  $(".btn1").click(function(){
    $("p").hide(1000, function(){
      document.getElementById("demo").innerHTML = "Hide() method is finished!";
    });
  });
  $(".btn2").click(function(){
    $("p").show(1000, function(){
      document.getElementById("demo").innerHTML = "Show() method is finished!";
    });
  });
});
</script>
</head>
<body>

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

<button class="btn1">Hide</button>
<button class="btn2">Show</button>

</body>
</html>



PreviousNext

Related