As the title, I need to let the number can continue increase after refresh the webpage but now the number will reset after refresh the webpage. Anyone know how to solve it?
Here is the number
<form method="POST">
<div style="background-color: white; display: flex; flex-wrap: nowrap; justify-content: space-evenly; margin-bottom: 15px; border-radius: 5px;">
<p id= "num" style="color: yellow; margin-top: 10px; margin-left: -15px;" class="number_border">0</p>
<p id= "num9" name = "num1" style="color: yellow; margin-top: 10px; margin-left: -15px;" class="number_border">0</p>
</div>
</form>
Here is the design of the number
<style type="text/css">
.number_border{
text-align: center;
border-radius: 5px;
background: red;
width: 20px;
height: 30px;
}
</style>
Here is the function to let the number can increase by 1 every 0.5 second
<script>
var number1 = 0;
var number2 = 0;
var el = document.getElementById('num1');
var el1 = document.getElementById('num');
function incrementSeconds() {
if (number1 < 9){
number1 += 1;
el.innerText = number1;
}else if (number2 < 9) {
number1 = 0;
el.innerText = number1;
number2 += 1;
el1.innerText = number2;
}
}
var increase = setInterval(incrementSeconds, 500);
</script>