How can I count from up from 0 to 100 in jQuery

count from up from 0 to 100%, You can use setInterval to update text with delay.

$("#update").click(function() {
  var count = 0;
  var innterval = setInterval(function() {
    if (count == 100)
      clearInterval(innterval);
    count++;
    $("#counter").html("My current count is: " + count + "%");
  }, 1000);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="update" type="button">Button</button>
<div id="counter">1</div>

Leave a Comment