Click to toggle dark text on white

Lession 3: jQuery Animation Callbacks

Callbacks are very important to jQuery animation because it determines what will happen after the animation is complete. Animation is a timed event, so for reasons of sanity, we shouldn't have to write separate timers to determine what should happen next:

Show Code

$(document).ready(function() {
    $("#clickhere").click(function() {
        $("#animate1").animate({
            height: "12px",
            width: "50px"
        }, 1000, function() {
            alert('done!');
        });
    });
});

The callback is always the last argument to jQuery.animate(), and always takes the form of a function.

<< What you can animate with jQuery Animation Easing >>

Wayfarer

Most Recent Blog Post: jQuery Mapbox Updated

Privacy Policy | Click Here | jQuery Plugins by Wayfarer | Freelance Jobs Available | Random JavaScript Code Samples | Share a Random Link | JavaScript Jobs