---
title: "JQuery callback method"  
description: "In JQuery callback function will execute when animation effect has finished. Assume that if animation effect applies on image and effect is not finish"  
author: "Sachindra Singh"  
published: 2011-02-22  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/467/jquery-callback-method  
category: "jquery"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# JQuery callback method

In JQuery callback function will execute when animation effect has finished. Assume that if animation effect applies on image and effect is not finished and execution is reached on next line then in this situation code will generate error, if we want to prevent such type of errors in code then we can use callback method. This method will executed when animation effect has been completed.\

##### Code:

```
<head>       <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>       <script type="text/javascript">         $(document).ready(function()        {            $("button").click(function()            {                $("img").hide(1000, function() //image will hide after animation effect then message will show(callback)                {                    alert("Image has hide");                });            });         });     </script></head><body>     <h2>         JQuery callback method</h2>     <img src="Lighthouse.jpg" id="img" style="height: 300px; width: 400px; position: relative" />    <br />     <br />     <button>         Click to hide</button></body></html>
```

![JQuery callback method](https://www.mindstick.com/mindstickarticle/962b9fcf-41b9-4093-9bcb-7e1ed2bbb8ab/images/b355de20-1f47-4603-93b7-59ae4025e89f.png)

If I will click on button,image will start disappear from page as shown below :

![JQuery callback method](https://www.mindstick.com/mindstickarticle/962b9fcf-41b9-4093-9bcb-7e1ed2bbb8ab/images/6a928848-ff64-42ba-b0ce-79934fb2ce01.png)

If image has disappeared from page, popup window will show message on page as shown below:

![JQuery callback method](https://www.mindstick.com/mindstickarticle/962b9fcf-41b9-4093-9bcb-7e1ed2bbb8ab/images/946d6431-7a1f-4842-aef9-0db5f60dc44e.png)

\

---

Original Source: https://www.mindstick.com/articles/467/jquery-callback-method

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
