SyntaxStudy
Sign Up
Home jQuery Reference .animate()

.animate()

method

Performs custom animations by gradually changing CSS numeric properties.

Syntax

$(selector).animate(properties, duration, easing, callback)

Example

javascript
// Slide right and fade
$('#box').animate({
    left: '250px',
    opacity: 0.5,
    height: '150px',
    width: '150px'
}, 500);

// Smooth scroll to top
$('html, body').animate({ scrollTop: 0 }, 600);

// Bounce counter
$({ count: 0 }).animate({ count: 100 }, {
    duration: 1000,
    step: function() {
        $('#counter').text(Math.ceil(this.count));
    }
});