jQuery: the animate() method

by Edgar Martinez

HTML

<p><button id="animate">animate()</button></p>

<div id="test"></div>

CSS

#test {
    margin: 2em auto;
    width: 10em;
    height: 10em;
    position: relative;
    background: gray;
}

JavaScript

var test = $('#test'),
    animate = $('#animate');

animate.click(function() {
    test.animate({
        left: 20,
        padding: '1em',
        opacity: 0.5,
				display:"none",
        margin: '1em 0',
        width: '5em',
        height: '5em'
    }, 1000, function() {
        alert('Complete');
    });
});