Realization method of jQuery Group Purchase Countdown special effect

  • 2020-06-07 03:58:32
  • OfStack

This paper illustrates the realization method of jQuery group purchase countdown special effect. Share to everybody for everybody reference. Specific implementation methods are as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Countdown test </title>
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
 function lxfEndtime(){
  var lxfday=$(this).attr("lxfday");// A variable used to determine whether the number of days is displayed 
  var endtime = new Date($(this).attr("endtime")).getTime();
  // End date ( Millisecond value )
  var nowtime = new Date().getTime();
  // Today's date ( Millisecond value )
  var youtime = endtime-nowtime;// How much longer does it take ( Millisecond value )
  var seconds = youtime/1000;
  var minutes = Math.floor(seconds/60);
  var hours = Math.floor(minutes/60);
  var days = Math.floor(hours/24);
  var CDay= days ;
  var CHour= hours % 24;
  var CMinute= minutes % 60;
  var CSecond= Math.floor(seconds%60);
  //"%" It's a mod operation, and you can view it as 60 Into the 1 And then I take the remainder, and then I just want the remainder. 
    $(this).html(" expired ")
    // If the end date is less than the current date, the prompt expires 
    $(this).html("<i> Remaining time: </i><span>"+CHour+"</span> when <span>"+CMinute+"</span> points <span>"+CSecond+"</span> seconds ");
    // Output data without days 
    $(this).html("<i> Remaining time: </i><span>"+days+"</span><em> day </em><span>"+CHour+"</span><em> when </em><span>"+CMinute+"</span><em> points </em><span>"+CSecond+"</span><em> seconds </em>");
    // Output days of data 
<style type="text/css">
  font-style: normal;
  font-weight: normal;}
.haveday {
  padding: 20px;
  border: 1px dashed #000;
  margin-right: auto;
  margin-left: auto;
  width: 300px;
<div class="haveday">
<h1> A countdown containing days </h1>
<div class="lxftime" endtime="11/15/2015 17:24:0"></div>
<div class="lxftime" endtime="11/8/2015 3:3:20"></div>
<div class="lxftime" endtime="9/6/2015 6:1:0"></div>
<div class="lxftime" endtime="6/6/2016 9:3:5"></div>
<div class="haveday">
<h1> There is no countdown of days </h1>
<div class="lxftime" endtime="11/15/2015 17:24:0" lxfday="no"></div>
<div class="lxftime" endtime="11/8/2015 3:3:20" lxfday="no"></div>
<div class="lxftime" endtime="9/6/2015 6:1:0" lxfday="no"></div>
<div class="lxftime" endtime="6/6/2016 9:3:5" lxfday="no"></div>

Hopefully, this article has been helpful in your jQuery programming.

Related articles: