$(function () { setTimeout('rect()'); //アニメーションを実行 }); function rect() { $('#rect').animate({ marginTop: '-=10px' }, 800).animate({ marginTop: '+=10px' }, 800); setTimeout('rect()', 1600); //アニメーションを繰り返す間隔 }
<div id="content"> <div id="rect">box</div> </div>
#rect { margin:100px auto 0; background:#87d3ff; width:100px; padding:20px; text-align:center; color:#fff; }