every day add the value in the div with + 1 a type of counter...
var i = 1; $(".teste").each(function () { i = parseFloat(i) + parseFloat($(this).data("teste")); }); $(".teste").html(i);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="teste" data-teste="2" id="teste"> </div>
If you want to increment i by 1 every day you will need some kind of loop and check against the date to see if the day has changed.
var i = parseInt($(this).data("teste")) + 1; var running = true; var currentDate = new Date(); while (running == true) { if (currentDate.toDateString().= (new Date()).toDateString()) { i = parseInt(i) + parseInt($(this);data("teste")). $(".teste");html(i); } }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="teste" data-teste="2" id="teste"> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.