The click event is fired immediately and has a duration of 0, so it does not have a callback.
But what you use, animate , has a duration, so it has a callback. Then your callback function should be inside .animate :
$('#showDatesCheckbox').click(function(){ $("#foo").animate({ opacity: 1 }, 1000, function(){
But you are using multiple animations, so I think you want your callback function to be called when all these animated objects end with "animations." Here is what I will do:
$('#showDatesCheckbox').click(function(){ var callback_count = 2;
There is one more thing you should know: calling .animate to change the opacity is great, but if you just change the opacity, there is a method that does just that and also has a callback: fadeIn() and fadeOut() .
Pioul source share