現在、デフォルトのフォント サイズが 24 のテキスト行があります。これをアニメーション化して、サイズを 22 に戻します。
$(document).ready(function animateHeader() {
$('#random_header').animate({fontSize : "22px"}, 500);
});
このアニメーションを 24 から 22 へ、22 から 24 へ連続的にループさせたいのですが、どうすればよいですか?
$(document).ready(function(){
function animateHeader(){
$('#random_header').animate({fontSize : 22}, 500,function(){
$(this).animate({fontSize : 24}, 500, animateHeader);
});
}
animateHeader();
});
$(document).ready(function animateHeader() {
$('#random_header').animate({
fontSize: $('#random_header').css('fontSize') == '24px' ? '22px' : '24px'
}, 500, animateHeader);
});
試す
function ani(size){
$('#random_header').animate({fontSize : size+"px"}, 500, function(){ ani((size==22) ? 24 : 22 ); } );
}
ani(24);