Jquery CallBack Tutorial
In this tutorial we will see how to use callback function in Jquery. Watch below video tutorial about Jquery Callback function.
You may have a task which depends upon completion of other task. However JavaScript executes the code line by line which may lead to an error. To ovecome such situations you can use Jquery CallBack functionality.
Source Code
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Jquery Callback function Tutorial</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$("document").ready(function () {
$("#button1").click(function () {
$("#div1").hide("slow", function() {
alert("Using call back");
});
});
$("#button2").click(function () {
$("#div1").hide("slow");
alert("without using call back");
});
});
</script>
</head>
<body>
<div id="div1" style="height: 500px; width: 500px;background-color:blue"> </div>
<input type="button" id="button1" value="Hide using CallBack">
<input type="button" id="button2" value="Hide without CallBack">
</body>
</html>
Watch free learning video tutorials about Jquery for beginners series at