html:
<span>hello world!</span>
js: (using callback)
$('span').click(function() {
$(this).animate({
fontSize: '+=10px'
}, 'slow', function() {
// callback after fontsize increased
$(this).text( $(this).text() + ' rolled! ' );
});
});
So that every time SPAN
is click, text 'rolled' appended after font size increased, instead of happening together.
And it can be done by using queue() as well like this:
js: (using queue())
$('span').click(function() {
$(this).animate({
fontSize: '+=10px'
}, 'slow'})
.queue(function() {
$(this).text( $(this).text() + ' rolled! ' );
});
});
I am not sure what is the difference between them. both do the same thing.
Why is queue() better/prefer than using callback, (or why is not ) ? What is special about queue()?
Thanks.