javascript - increment value of a number with a specific timer-value -


i've tried , looked around not find similar.

<div> <span>23</span>/ 30 </div> 

my thought process here want 23 increment in 1 value every 15th second.

and when hits 30, shall stop counting. have no idea how make "stop" counting , how should approach problem this.

any appreciated!

here possible solution, note iteration every second demo, can lower rate doing settimeout(count,15000);.

var wrapper, value, timer;    window.addeventlistener('load', startcounter, false);    function startcounter(){      document.queryselector('button').onclick = startcounter;      wrapper = document.queryselector('span');      value = 22;      count();  }    function count(){      cleartimeout(timer);      value++;      wrapper.innerhtml = value;      if(value < 30){ timer = settimeout(count,1000); }  }
<div> <span>23</span>/ 30 </div>    <button>reset</button>


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -