html:
<span>hello world!</span>
js :(コールバックを使用)
$('span').click(function() {
$(this).animate({
fontSize: '+=10px'
}, 'slow', function() {
// callback after fontsize increased
$(this).text( $(this).text() + ' rolled! ' );
});
});
クリックするたびSPAN
に、フォントサイズが大きくなった後、テキスト「rolled」が一緒に発生するのではなく、追加されます。
そして、それは次のようにqueue()を使用して行うことができます:
js :( queue()を使用)
$('span').click(function() {
$(this).animate({
fontSize: '+=10px'
}, 'slow'})
.queue(function() {
$(this).text( $(this).text() + ' rolled! ' );
});
});
それらの違いはわかりません。どちらも同じことをします。
なぜqueue()はコールバックを使用するよりも優れている/好むのですか(またはなぜそうではないのですか)?queue()の何が特別なのですか?
ありがとう。