単純な3-2-1カウンターを作成しようとしています。3、2、1を表示し、カウントダウンの最後に関数を実行したいと思います。私は役に立たないいくつかのことを試みました:
$("#count_num").delay(1000).queue(function() {
$(this).html("2")
});
$("#count_num").delay(1000).queue(function() {
$(this).html("1")
});
と:
$("#count_num").delay(1000).queue(function() {
$(this).html("2").delay(1000).queue(function() {
$(this).html("1")
});
});
これらの場合、2になりますが、1にはなりません。doTimeoutプラグイン(http://benalman.com/projects/jquery-dotimeout-plugin/)もインストールして、これを試しました。
$.doTimeout( 1000, function(){
$("#count_num").html("2");
});
$.doTimeout( 1000, function(){
$("#count_num").html("1");
});
と:
var count=3;
$.doTimeout( 1000, function(){
if ( count==1 ) {
// do something finally
return false;
}
$("#count_num").html(count);
count--;
return true;
});
私は何が間違っているのですか?ありがとう。