A call back function executed after the current event has completed. Java Script code executes line by line. However, if next line of code executes even before completing the action(s) which wrote in previous lines. This may create an error. To avoid this, we can create Callback function.
JQuery Callback Function Syntax
Syntax: $(selector).hide(speed,callback);
To avoid this we can create aa callback function Below is a sample script for jQuery Callback function.
<script>
$(document).ready(function () {
$("button").click(function () {
$("p").hide("slow", function () {
alert("This line is now hide.");
});
});
});
</script>
You may like this - 5 Essential Points to Become a skilled Full Stack Developer
Other blogs on JQuery
- Consume Web API 2 using JQuery in MVC application
- Upload a file using JQuery and Generic Handler in ASP.Net
- JQuery Events Methods
- Calling ASP.Net WebMethod using jQuery AJAX
- How to Crop and Upload image using JQuery