Welcome to FindNerd,
Today we are going to discuss on Callback Function in jQuery.
Firstly let know what is the use of Callback Function ?
This function is executed after the current effect is finished.
In simple way we can say that callback parameter that is a function that will be executed after the hide effect is completed:
syntax of callback function
$(selector).hide(speed,callback);
<!DOCTYPE html>
<html>
<head>
<!-- here call the jquery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").hide("slow", function(){ // here weite callback function
alert("Message! This text is hidden now");
});
});
});
</script>
</head>
<body>
<!-- here define a hide button for execuiting function -->
<button>Hide Button</button>
<p>This is a example of callback function</p>
</body>
</html>
0 Comment(s)