javascript - How to animate like button numbers with jQuery? -
how add together effect jquery's text() function. have code:
$('#a1').text(number($('#a1').text()) + 1);
this code changes value of <span>
tag.
how can add together effect this?
i have tried:
$('#a1').text(number($('#a1').text()) + 1).slidedown('slow');
but i'm missing something...
you utilize simple animation jquery's animate
. example:
var duration = 500; var $d = $('#div'); var $s = $('#span'); $d.click(function() { var $newnum = $('<span>').text('3').css({ position: 'absolute', bottom: $s.height() }).appendto($d); $newnum.animate({ bottom: 0 }, { duration: duration, }); $s.animate({ top: $s.height(), height: 0 }, { duration: duration, complete: function() { $s.remove(); } }); });
and html:
<div id='div' style='position:relative'>amount: 1<span id='span' style='position:absolute'>2</span></div>
here's jsfiddle.
javascript jquery
No comments:
Post a Comment