Hit Hit - 15 days ago 6
CSS Question

How to add 2 to the current value at every one minute?

My HTML and CSS code is here. Every no. is in diffrent span tag.
I need like 152,242 after 1 minute, 152,244 after 2 minutes and so on. I was trying to do it with jquery but i did not get the perfect output.



#hp_header .number{
display: inline-block;
width: 100%;
text-align: center;
margin-top: 40px;
}
#hp_header .number .number_inner{
display: inline-block;
text-align: center;
color: #282828;
font-family: SourceSansPro-Regular !important;
font-size: 32px;
}
#hp_header .number .count{
font-family: SourceSansPro-Regular !important;
font-size: 32px;
color: #f0f1b4;
padding: 5px 10px;
background-color: #282828;
margin: 0px 5px;
}
#hp_header .number .members_count {
width: 100%;
float: left;
margin-top: 10px;
color: #282828;
font-family: SourceSansPro-Regular !important;
text-transform: uppercase;
letter-spacing: 5px;
}

<div id="hp_header">
<span class="number">
<span class="number_inner">
<span class="count">1</span>
<span class="count">5</span>
<span class="count">2</span>
,
<span class="count">2</span>
<span class="count">4</span>
<span class="count">2</span>
</span>
</span>
</div>





Thanks in advance.

Answer

Hope below code will help you. For testing i put 2 seconds interval(2000). You can make it (60000) for each minute

setInterval(oneSecondFunction, 2000);
function oneSecondFunction() {
   total = document.getElementsByClassName('count').length;	
   values = document.getElementsByClassName('count');
   current_value='';
  
   for(i=0;i<total;i++)
   {
	   
	   current_value+=values[i].innerHTML;
	   
   }
   new_value = parseInt(current_value)+2;
   
   new_value_string=new_value.toString();

   for(j=0;j<new_value_string.length;j++)
   {
	   values[j].innerHTML = new_value_string[j];
   }
  
}
#hp_header .number{
    display: inline-block;
    width: 100%;
    text-align: center;
    margin-top: 40px;
}
#hp_header .number .number_inner{
    display: inline-block;
    text-align: center;
    color: #282828;
    font-family: SourceSansPro-Regular !important;
    font-size: 32px;
}
#hp_header .number .count{
    font-family: SourceSansPro-Regular !important;
    font-size: 32px;
    color: #f0f1b4;
    padding: 5px 10px;
    background-color: #282828;
    margin: 0px 5px;
}
#hp_header .number .members_count {
    width: 100%;
    float: left;
    margin-top: 10px;
    color: #282828;
    font-family: SourceSansPro-Regular !important;
    text-transform: uppercase;
    letter-spacing: 5px;
}
<div id="hp_header">
  <span class="number">
    <span class="number_inner">
      <span class="count">1</span>
      <span class="count">5</span>
      <span class="count">2</span>
      ,
      <span class="count">2</span>
      <span class="count">4</span>
      <span class="count">2</span>
    </span>
  </span>
</div>