Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Callback Function in jQuery

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 283
    Comment on it

    Callback Functions:

    It is used to prevent executing further code until earlier effects has not executed completely. As we know in jQuery effects takes time to complete and sometime next line code get executed while the earlier effects are still executing.


    <!DOCTYPE html>
    <html lang="en">
    <meta charset="UTF-8">
    <title>Callback Functions</title>
    <script src=""></script>
    <script type="text/javascript">
            $("p").slideToggle("slow", function(){
                alert(" Effect  completed successfully.");
    	<div class="container">
    	    <p>Demo of Callback Function in jQuery</p>
    	    <div style="text-align:center;"><button type="button">Click me</button></div>

    In the above example we used alert() statement inside callback function for slideToggle() method. And when we run the above code the message written inside alert() statement will be displayed only when the slide toggle effect has completed.


    You can check the output of above example here:

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: