Skip to content

Instantly share code, notes, and snippets.

@fronteer-kr
Last active August 29, 2015 14:02
Show Gist options
  • Save fronteer-kr/0b93740ccad1fa0d91fc to your computer and use it in GitHub Desktop.
Save fronteer-kr/0b93740ccad1fa0d91fc to your computer and use it in GitHub Desktop.
jQuery Animate - 변수값만으로도..
var rn = Math.round(Math.random() * 99999);
$("#msg").text("Random Number = " + rn);
var $el = $("#number1");
$({ val : 0 }).animate({ val : rn }, {
duration: 2000,
step: function() {
$el.text(Math.floor(this.val).cf());
},
complete: function() {
$el.text(Math.floor(this.val).cf());
}
});
// cf() 는 천단위 comma용 (prototype 에 미리 정의해 둠)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment