From ffcc5c1a6c6bba8121db8d94ca6db84ca2c213c7 Mon Sep 17 00:00:00 2001 From: Xiaolei <196521591@qq.com> Date: Thu, 7 Jan 2016 19:07:27 -0600 Subject: [PATCH] fixed the problem that the number will change when loading several times --- jquery.counterup.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jquery.counterup.js b/jquery.counterup.js index bc7871f..8bd2f18 100644 --- a/jquery.counterup.js +++ b/jquery.counterup.js @@ -24,9 +24,12 @@ var $settings = settings; var counterUpper = function() { - var nums = []; + if(!$this.data('counterupTo')){ + $this.data('counterupTo',$this.text()); + } var divisions = $settings.time / $settings.delay; - var num = $this.text(); + var num = $this.data('counterupTo'); + var nums = [num]; var isComma = /[0-9]+,[0-9]+/.test(num); num = num.replace(/,/g, ''); var isInt = /^[0-9]+$/.test(num);