.animate

JS - ANIMATE -1

要做動畫的 DOM,position 不能為 static。

$('#BtnRight').click(function () {
    $('#Rocket').animate({ left: 1000 }, 500);
});
$('#BtnLeft').click(function () {
        $('#Rocket').animate({ left: 0 }, 500);
});

JS - ANIMATE -2

$('#BtnRight').click(function () {
    $('#Rocket').stop(true, false).animate({ left: '+=200' }, 500);
});
$('#BtnLeft').click(function () {
    $('#Rocket').stop(true, false).animate({ left: '-=200' }, 500);
});

Last updated

Was this helpful?