jQuery Callback


The jQuery callback function is executed when the effect completes. Each such method accepts the callback function as a parameter to be executed when the effect is completed. As an example, if we are passing a callback function to the slideToggle() method, the callback function will be executed when the slideToggle effect is completed.

Example

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").slideToggle("slow", function(){
            alert("The slideToggle effect is complete");
        });
  });
});
</script>
</head>
<body>
 <p>This is paragraph tag.</p>
  <button>Click here</button>
</body>
</html>