title: javascript countdown timer inside php loop not working
body: <p><em>Hi I am trying to add multiple countdown timer through  javascript but some how, its not working , Can any one tell me what I am doing wrong, I am a new bee.</em></p>
  
  <p>below is by code:</p>
  
  <pre><code>php while loop {
  
      &lt;script&gt;
      var timer;
  
      var days= &lt;?php echo $datediff ; ?&gt;;     
  
      var compareDate = new Date();
      compareDate.setDate(compareDate.getDate() + &lt;?php echo $datediff  ?&gt; ); //just for this demo today + 7 days
  
      timer = setInterval(function() {
          timeBetweenDates(compareDate);
      }, 1000);
  
      function timeBetweenDates(toDate) {
          var dateEntered = toDate;
          var now = new Date();
          var difference = dateEntered.getTime() - now.getTime();
  
          if (difference &lt;= 0) {
              // Timer done
              clearInterval(timer);
          } else {
              var seconds = Math.floor(difference / 1000);
              var minutes = Math.floor(seconds / 60);
              var hours = Math.floor(minutes / 60);
              var days = Math.floor(hours / 24);
  
              hours %= 24;
              minutes %= 60;
              seconds %= 60;
  
              $(".days") .text(days);
              $(".hours").text(hours);
              $(".minutes").text(minutes);
              $(".seconds").text(seconds);
         }    
      }
      &lt;/script&gt;
      &lt;div class="timer"&gt;
          &lt;span class="days"&gt;&lt;/span&gt;days
          &lt;span class="hours"&gt;&lt;/span&gt;hours
          &lt;span class="minutes"&gt;&lt;/span&gt;minutes
          &lt;span class="seconds"&gt;&lt;/span&gt;seconds
      &lt;/div&gt;
  </code></pre>
  
  <p>I am not able to get the timer work have changed the id to class.</p>